diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index d2e14e0fa..c172d7712 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -458,11 +458,6 @@ doit(struct line *deck, wordlist *modnames) { /* c points to the opening .subckt card */ /* ends points to the terminating .ends card */ - /* cut the whole .subckt ... .ends sequence from the deck chain */ - if (prev_of_c) - prev_of_c->li_next = ends->li_next; - else - deck = ends->li_next; /* Now put the .subckt definition found into sss */ @@ -494,9 +489,16 @@ doit(struct line *deck, wordlist *modnames) { sss->su_next = subs; subs = sss; + /* cut the whole .subckt ... .ends sequence from the deck chain */ + line_free_x(c, FALSE); c = ends->li_next; + if (prev_of_c) + prev_of_c->li_next = ends->li_next; + else + deck = ends->li_next; + if (use_numparams == FALSE) { line_free_x(ends, FALSE); /* drop the .ends card */ prev_of_ends->li_next = NULL;