Prevent crash if not enough nodes for standard MOS device

This commit is contained in:
Holger Vogt 2020-04-28 18:59:18 +02:00
parent 8ea51cc2f3
commit b0f99b900e
1 changed files with 7 additions and 0 deletions

View File

@ -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");