From 2a3c88add688ff1a6a34767b4f37652a518b96a4 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 19 Sep 2018 00:01:44 +0200 Subject: [PATCH] Commit ad0f59657 ("fix a memory leak", 2018-08-13) made the special device parameter notation @m1[vt0] unusable. This fix frees only the tokens that are already overridden in function INPinsertNofree(). The reason for using this function instead of INPinsert() is not obvious. --- src/frontend/outitf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 96ea0dea1..e434bcd45 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -449,6 +449,7 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind) { dataDesc *data; char *unique, *freeunique; /* unique char * from back-end */ + int ret; if (!run->numData) run->data = TMALLOC(dataDesc, 1); @@ -463,11 +464,12 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind) freeunique = unique = copy(devname); - /* MW. My "special" routine here */ - INPinsertNofree(&unique, ft_curckt->ci_symtab); - data->specName = copy(unique); + /* unique will be overridden, if it already exists */ + ret = INPinsertNofree(&unique, ft_curckt->ci_symtab); + data->specName = unique; - tfree(freeunique); + if (ret == E_EXISTS) + tfree(freeunique); data->specParamName = copy(param); @@ -1253,7 +1255,6 @@ freeRun(runDesc *run) for (i = 0; i < run->numData; i++) { tfree(run->data[i].name); tfree(run->data[i].specParamName); - tfree(run->data[i].specName); } tfree(run->data);