From cf825fd80a6b3308abd7c0f9b32fdcf5d6565593 Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Sat, 16 May 2026 13:22:48 -0700 Subject: [PATCH] Fix memory leaks for paranoia_parallel. Tests with leaks: examples/various/probe-i-dev.cir examples/vdmos/100W.sp multiple tests using OUTpBeginPlot, add_to_sourcepath --- src/frontend/inpc_probe.c | 10 +++++----- src/frontend/inpcom.c | 1 + src/frontend/outitf.c | 6 +++--- src/maths/ni/niiter.c | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/frontend/inpc_probe.c b/src/frontend/inpc_probe.c index 5a7a91f54..ddd1e4630 100644 --- a/src/frontend/inpc_probe.c +++ b/src/frontend/inpc_probe.c @@ -142,7 +142,7 @@ void inp_probe(struct card* deck) } /* don't free the wl_word, they belong to the cards */ wltmp = probes; - while (wltmp) { + while (wltmp) { // Fix memory leak probe-i-dev.cir next_wl = wltmp->wl_next; tfree(wltmp); // Do not free the wl_word wltmp = next_wl; @@ -194,7 +194,7 @@ void inp_probe(struct card* deck) if (!instname) continue; nghash_insert(instances, instname, card); - tfree(instname); + tfree(instname); // Fix memory leak probe-i-dev.cir } if (haveall || probeparams == NULL) { @@ -893,7 +893,7 @@ void inp_probe(struct card* deck) tmpcard = nghash_find(instances, instname); if (!tmpcard) { fprintf(stderr, "Warning: Could not find the instance line for %s,\n .probe %s will be ignored\n", instname, wltmp->wl_word); - tfree(instname); + tfree(instname); // Fix memory leak probe-i-dev.cir continue; } char* thisline = tmpcard->line; @@ -929,7 +929,7 @@ void inp_probe(struct card* deck) else if (err == 3) { fprintf(stderr, "Warning: Number of nodes mismatch,\n .probe %s will be ignored\n", wltmp->wl_word); } - tfree(instname); + tfree(instname); // Fix memory leak probe-i-dev.cir continue; } else if (!haveall) { @@ -948,7 +948,7 @@ void inp_probe(struct card* deck) } if (probeparams) { - wl_free(probeparams); + wl_free(probeparams); // Fix memory leak probe-i-dev.cir } nghash_free(instances, NULL, NULL); } diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 3551975ef..5943c8118 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -9944,6 +9944,7 @@ int add_to_sourcepath(const char* filepath, const char* path) scan_new = next; } if (!addwl) { + wl_free(startwl); wl_free(wl); tfree(fpath); return 0; // Not an error. diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index a59dc6030..b2ef4681e 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -153,11 +153,11 @@ OUTpBeginPlot(CKTcircuit *circuitPtr, JOB *analysisPtr, " is more than the DRAM memory available (%sB)!\n", cmemrequ, n, ctimesteps, cmemavail); fprintf(stderr, " Swapping data to SSD may slow down the simulation.\n"); - tfree(cmemrequ); - tfree(cmemavail); - tfree(ctimesteps); #endif } + tfree(cmemrequ); + tfree(cmemavail); + tfree(ctimesteps); } return ret; diff --git a/src/maths/ni/niiter.c b/src/maths/ni/niiter.c index 85da8ecd7..9f06a62df 100644 --- a/src/maths/ni/niiter.c +++ b/src/maths/ni/niiter.c @@ -278,6 +278,7 @@ NIiter(CKTcircuit *ckt, int maxIter) fprintf(stderr, "too many iterations without convergence: %d iter's (max iter == %d)\n", iterno, maxIter); #endif + FREE(errMsg); } FREE(OldCKTstate0); return(E_ITERLIM);