free only value that have been TMALLOCed or TREALLOCed

This commit is contained in:
Holger Vogt 2018-09-22 18:25:06 +02:00
parent 5f5ec4f49a
commit a17de08b5c
1 changed files with 8 additions and 2 deletions

View File

@ -200,8 +200,14 @@ char *MIFgetMod(
ft_sim->devices[modtmp->INPmodType]->modelParms[j].id,
val, NULL);
/* free val, allocated by MIFgetValue */
int vtype = (ft_sim->devices[modtmp->INPmodType]->modelParms[j].dataType & IF_VARTYPES);
if (vtype == IF_FLAGVEC || IF_INTVEC)
tfree(val->v.vec.iVec);
if (vtype == IF_REALVEC)
tfree(val->v.vec.rVec);
if (IF_STRING == (ft_sim->devices[modtmp->INPmodType]->modelParms[j].dataType & IF_VARTYPES))
if (vtype == IF_CPLXVEC)
tfree(val->v.vec.cVec);
if (vtype == IF_STRING || vtype == IF_STRINGVEC)
tfree(val->sValue);
if(error)
return(INPerror(error));