Index: ../trunk-jpl/src/c/classes/FemModel.cpp =================================================================== --- ../trunk-jpl/src/c/classes/FemModel.cpp (revision 18889) +++ ../trunk-jpl/src/c/classes/FemModel.cpp (revision 18890) @@ -89,6 +89,7 @@ FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, ISSM_MPI_Comm incomm, int solution_type,IssmPDouble* X){ /*{{{*/ bool traceon=true; + this->profiler=NULL; /*avoid leak, as we are not using the profiler ever in ad control run. */ /*Store the communicator, but do not set it as a global variable, as this has already * been done by the FemModel that called this copy constructor: */ @@ -111,21 +112,20 @@ this->parameters->FindParam(&lockfilename,LockFileNameEnum); /*Delete all the datasets: */ - xDelete(analysis_type_list); - xDelete(outbinfilename); - xDelete(lockfilename); - delete elements; - delete nodes; - delete vertices; - delete constraints; - delete loads; - delete materials; - delete parameters; - delete results; + if(analysis_type_list)xDelete(analysis_type_list); + if(outbinfilename)xDelete(outbinfilename); + if(lockfilename)xDelete(lockfilename); + if(elements)delete elements; + if(nodes)delete nodes; + if(vertices)delete vertices; + if(constraints)delete constraints; + if(loads)delete loads; + if(materials)delete materials; + if(parameters)delete parameters; + if(results)delete results; /*Now delete: */ - delete profiler; - + if(profiler)delete profiler; } /*}}}*/