Commit 19a86fbe authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Fix minor memory leaks.

parent 095eda90
......@@ -280,9 +280,10 @@ void instituteDestroyP ( void * instituteptr )
id = i1->self;
if ( instituteptr ) free ( instituteptr );
free(i1->name);
free(i1->longname);
reshRemove ( id, &instituteOps );
free(instituteptr);
}
......@@ -343,13 +344,14 @@ int instituteUnpack(void *buf, int size, int *position, int nspTarget, void *con
int instituteID;
char *name, *longname;
serializeUnpack(buf, size, position, tempbuf, institute_nints, DATATYPE_INT, context);
name = (char*) xmalloc(tempbuf[3]);
longname = (char*) xmalloc(tempbuf[4]);
name = (char *)xmalloc(tempbuf[3] + tempbuf[4]);
longname = name + tempbuf[3];
serializeUnpack(buf, size, position, name, tempbuf[3], DATATYPE_TXT, context);
serializeUnpack(buf, size, position, longname, tempbuf[4], DATATYPE_TXT, context);
instituteID = institutDef(tempbuf[1], tempbuf[2], name, longname);
// FIXME: this should work, once all types are transferred
//xassert(instituteID == tempbuf[0]);
free(name);
return instituteID;
}
......
......@@ -252,6 +252,10 @@ int modelCompareP ( void * modelptr1, void * modelptr2 )
void modelDestroyP ( void * modelptr )
{
model_t *mp = modelptr;
if (mp->name)
free(mp->name);
free(mp);
}
......@@ -319,6 +323,8 @@ modelUnpack(void *buf, int size, int *position, int nspTarget, void *context)
}
modelID = modelDef( namespaceAdaptKey ( tempbuf[1], nspTarget ), tempbuf[2], name);
if (tempbuf[3] != 0)
free(name);
// FIXME: this should work, once all types are transferred
//assert(modelID == tempbuf[0]);
return modelID;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment