Index: /issm/trunk-jpl/src/c/shared/Alloc/alloc_module.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Alloc/alloc_module.cpp	(revision 12851)
+++ /issm/trunk-jpl/src/c/shared/Alloc/alloc_module.cpp	(revision 12852)
@@ -22,9 +22,7 @@
 		/*Actually, still get rid of internal Petsc matrix. Quick fix until Matlab handles C++ 
 		 * correctly: */
-		/*Keeping this for legacy reasons: */
-		/*#ifdef _HAVE_PETSC_
-			MatFree(&(*pv)->matrix);
-		#endif*/
-		delete *pv;
+		#ifdef _HAVE_PETSC_
+			MatFree(&(*pv)->pmatrix->matrix);
+		#endif
 		*pv=NULL;
 	}
@@ -36,9 +34,7 @@
 		/*Actually, still get rid of internal Petsc vector. Quick fix until Matlab handles C++ 
 		 * correctly: */
-		/*Keeping this for legacy reasons: shoudl be done by the vector itself!*/
-		/*#ifdef _HAVE_PETSC_
-			VecFree(&(*pv)->vector);
-		#endif*/
-		delete *pv;
+		#ifdef _HAVE_PETSC_
+			VecFree(&(*pv)->pvector->vector);
+		#endif
 		*pv=NULL;
 	}
