Commits

Jed Brown  committed 62d839e

DMClearGlobalVectors: fix reference-counting loop

Reported-by: Patrick Farrell <patrick.farrell@maths.ox.ac.uk>

  • Participants
  • Parent commits 8c6db3d

Comments (0)

Files changed (1)

File src/dm/interface/dmget.c

   PetscFunctionBegin;
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
   for (i=0; i<DM_MAX_WORK_VECTORS; i++) {
+    Vec g;
     if (dm->globalout[i]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Clearing DM of global vectors that has a global vector obtained with DMGetGlobalVector()");
-    ierr = VecDestroy(&dm->globalin[i]);CHKERRQ(ierr);
+    g = dm->globalin[i];
+    dm->globalin[i] = NULL;
+    ierr = VecDestroy(&g);CHKERRQ(ierr);
   }
   PetscFunctionReturn(0);
 }