diff --git a/src/spicelib/parser/inp2m.c b/src/spicelib/parser/inp2m.c index 488f28b83..5594f0864 100644 --- a/src/spicelib/parser/inp2m.c +++ b/src/spicelib/parser/inp2m.c @@ -75,6 +75,7 @@ INP2M(CKTcircuit *ckt, INPtables *tab, struct card *current) for (i = 0; ; i++) { char *token; INPgetNetTok(&line, &token, 1); + if (i >= 3) { txfree(INPgetMod(ckt, token, &thismodel, tab)); @@ -94,6 +95,12 @@ INP2M(CKTcircuit *ckt, INPtables *tab, struct card *current) INPtermInsert(ckt, &token, tab, &node[i]); } + /* We have at least 4 nodes, except for VDMOS */ + if (i == 3 && thismodel->INPmodType != INPtypelook("VDMOS")) { + LITERR("not enough nodes"); + return; + } + int model_numnodes_ = model_numnodes(thismodel->INPmodType); if (i > model_numnodes_) { LITERR ("too many nodes connected to instance");