1. petsc
  2. PETSc
  3. petsc

Commits

Jed Brown  committed 55d43fd Merge

Merge branch 'madams/petsc-mem'

* madams/petsc-mem:
MatView_SeqAIJ_ASCII: fix out-of-bounds access when matrix has 0 rows
MatMatTransposeMultNumeric_SeqAIJ_SeqAIJ: fix out-of-bounds memory access

  • Participants
  • Parent commits 3630d66, 014b3a6
  • Branches master

Comments (0)

Files changed (2)

File src/mat/impls/aij/seq/aij.c

View file
  • Ignore whitespace
   ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
   if (format == PETSC_VIEWER_ASCII_MATLAB) {
     PetscInt nofinalvalue = 0;
-    if ((a->i[m] == a->i[m-1]) || (a->j[a->nz-1] != A->cmap->n-!shift)) {
+    if (m && ((a->i[m] == a->i[m-1]) || (a->j[a->nz-1] != A->cmap->n-!shift))) {
       nofinalvalue = 1;
     }
     ierr = PetscViewerASCIIUseTabs(viewer,PETSC_FALSE);CHKERRQ(ierr);

File src/mat/impls/aij/seq/matmatmult.c

View file
  • Ignore whitespace
 #else
       nexta = 0; nextb = 0;
       while (nexta<anzi && nextb<bnzj) {
-        while (acol[nexta] < bcol[nextb] && nexta < anzi) nexta++;
+        while (nexta < anzi && acol[nexta] < bcol[nextb]) nexta++;
         if (nexta == anzi) break;
-        while (acol[nexta] > bcol[nextb] && nextb < bnzj) nextb++;
+        while (nextb < bnzj && acol[nexta] > bcol[nextb]) nextb++;
         if (nextb == bnzj) break;
         if (acol[nexta] == bcol[nextb]) {
           cval[j] += aval[nexta]*bval[nextb];