From 4f5c23ba44e488c386303a748287beda06ad6faf Mon Sep 17 00:00:00 2001 From: Brian Taylor Date: Sat, 27 Sep 2025 12:16:39 -0700 Subject: [PATCH] Add a correction to the previous change of inppas4.c, which freed devname and left instance name pointers in DEVnameHash pointing at freed memory. This commit adds the devname string to the symbol tables which are eventually cleared by INPtabEnd. Also, if a capacitor in the spice netlist has the same name (unlikely, but possible) as a shunt capacitor, then no shunt is created, and a warning is issued. --- src/spicelib/parser/inppas4.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/spicelib/parser/inppas4.c b/src/spicelib/parser/inppas4.c index dd6096577..d30283c8b 100644 --- a/src/spicelib/parser/inppas4.c +++ b/src/spicelib/parser/inppas4.c @@ -57,8 +57,24 @@ void INPpas4(CKTcircuit *ckt, INPtables *tab) int nn = node->number; char* devname = tprintf("capac%dshunt", nn); - (*(ft_sim->newInstance))(ckt, tab->defCmod, &fast, devname); - txfree(devname); + fast = (*(ft_sim->findInstance))(ckt, devname); + if (fast) { + fprintf(stderr, + "WARNING: non-cshunt instance %s already exists\n", + devname); + tfree(devname); + continue; + } + error = (*(ft_sim->newInstance))(ckt, tab->defCmod, &fast, devname); + if (error) { + fprintf(stderr, + "ERROR: cshunt newInstance status %d devname %s\n", + error, devname); + tfree(devname); + continue; + } + /* devname is eventually freed when INPtabEnd is called */ + INPinsert(&devname, tab); /* the top node, second node is gnd automatically */ (*(ft_sim->bindNode))(ckt, fast, 1, node);