From aa27c8969cce00dca915c9900492bfcfdfbccf9a Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 10 Jan 2018 13:14:02 +0100 Subject: [PATCH] parser/inpgmod.c, fix an almost bug, (level=...) When 'level' is a valid model parameter, then it was processed like any other parameter, but additionally the `if (strcmp(parm, "level") == 0)' invoked INPgetValue() a second time. This special processing is meant to allow "level" for all models whether they make use of it or not. The excess invocation of INPgetValue() didn't cause harm, merely because the next token after the "level=number" almost necessarily is a string (the beginning "name=" of the next assignment) thus not a parse-able number, thus the second INPgetValue() didn't modify the 'line' pointer. To sanitise the code invoke the "level" skipping only if "level" is not recognised as a valid model parameter. --- src/spicelib/parser/inpgmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index 430d0f5c0..8485006a1 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -105,7 +105,7 @@ create_model(CKTcircuit *ckt, INPmodel *modtmp, INPtables *tab) } } - if (strcmp(parm, "level") == 0) { + if (j >= *(ft_sim->devices[modtmp->INPmodType]->numModelParms) && strcmp(parm, "level") == 0) { /* just grab the level number and throw away */ /* since we already have that info from pass1 */ val = INPgetValue(ckt, &line, IF_REAL, tab);