Commits

Peter Brune  committed e2c616c

Fixed memory leak in DMCreateDomainDecomposition_DA() related to names.

  • Participants
  • Parent commits 90c7789

Comments (0)

Files changed (1)

File src/dm/impls/da/dadd.c

   ierr = DMDASubDomainDA_Private(dm,&n,&sdm);CHKERRQ(ierr);
   if (names) {
     ierr = PetscMalloc(n*sizeof(char*),names);CHKERRQ(ierr);
-    for (i=0;i<n;i++) names[i] = 0;
+    for (i=0;i<n;i++) (*names)[i] = 0;
   }
   ierr = DMDASubDomainIS_Private(dm,n,sdm,iis,ois);CHKERRQ(ierr);
   if (subdm) *subdm = sdm;
+  else {
+    for (i=0;i<n;i++) {
+      ierr = DMDestroy(&sdm[i]);CHKERRQ(ierr);
+    }
+  }
   if (len) *len = n;
   PetscFunctionReturn(0);
 }