From 44cca07fea3947f8b18d83a3170fd488ebb8023b Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 18 Feb 2020 22:59:36 +0100 Subject: [PATCH] plug a memory leak in inpcom.c vdmos code --- src/frontend/inpcom.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index d4f440f7d..fdc7393fe 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -6935,10 +6935,10 @@ static int inp_vdmos_model(struct card *deck) wl_append_word(&wl, &wl, copy_substring(curr_line, cut_line)); wlb = wl; if (strstr(cut_line, "pchan")) { - wl_append_word(NULL, &wl, "vdmosp ("); + wl_append_word(NULL, &wl, copy("vdmosp (")); } else { - wl_append_word(NULL, &wl, "vdmosn ("); + wl_append_word(NULL, &wl, copy("vdmosn (")); } cut_line = cut_line + 5; @@ -6949,17 +6949,20 @@ static int inp_vdmos_model(struct card *deck) while (cut_line && *cut_line) { token = gettok_model(&cut_line); if (!ciprefix("pchan", token) && !ciprefix("ron=", token) && - !ciprefix("vds=", token) && !ciprefix("qg=", token) && - !ciprefix("mfg=", token) && !ciprefix("nchan", token)) + !ciprefix("vds=", token) && !ciprefix("qg=", token) && + !ciprefix("mfg=", token) && !ciprefix("nchan", token)) wl_append_word(NULL, &wl, token); + else + tfree(token); if (*cut_line == ')') { - wl_append_word(NULL, &wl, ")"); + wl_append_word(NULL, &wl, copy(")")); break; } } new_line = wl_flatten(wlb); tfree(card->line); card->line = new_line; + wl_free(wlb); } /* we have a VDMOS instance line with 'tnodeout' and thus need exactly 5 nodes */