Prevent seg fault after strange input like
*no circuit .save all .probe alli .op .end
This commit is contained in:
parent
098ec89294
commit
012ec72b0d
|
|
@ -1215,23 +1215,25 @@ static char* get_terminal_number(char* element, char* namestr)
|
||||||
Called from inp.c*/
|
Called from inp.c*/
|
||||||
void modprobenames(INPtables* tab) {
|
void modprobenames(INPtables* tab) {
|
||||||
GENinstance* GENinst;
|
GENinstance* GENinst;
|
||||||
for (GENinst = tab->defVmod->GENinstances; GENinst; GENinst = GENinst->GENnextInstance) {
|
if (tab->defVmod) {
|
||||||
char* name = GENinst->GENname;
|
for (GENinst = tab->defVmod->GENinstances; GENinst; GENinst = GENinst->GENnextInstance) {
|
||||||
if (prefix("vcurr_", name)) {
|
char* name = GENinst->GENname;
|
||||||
/* copy from char no. 6 to (and excluding) second colon */
|
if (prefix("vcurr_", name)) {
|
||||||
char* endname = strchr(name, ':');
|
/* copy from char no. 6 to (and excluding) second colon */
|
||||||
char* endname2 = strchr(endname + 1, ':');
|
char* endname = strchr(name, ':');
|
||||||
/* two-terminal device, one colon, copy all from char no. 6 to (and excluding) colon */
|
char* endname2 = strchr(endname + 1, ':');
|
||||||
if (!endname2) {
|
/* two-terminal device, one colon, copy all from char no. 6 to (and excluding) colon */
|
||||||
char* newname = copy_substring(name + 6, endname);
|
if (!endname2) {
|
||||||
memcpy(name, newname, strlen(newname) + 1);
|
char* newname = copy_substring(name + 6, endname);
|
||||||
tfree(newname);
|
memcpy(name, newname, strlen(newname) + 1);
|
||||||
}
|
tfree(newname);
|
||||||
/* copy from char no. 6 to (and excluding) second colon */
|
}
|
||||||
else {
|
/* copy from char no. 6 to (and excluding) second colon */
|
||||||
char* newname = copy_substring(name + 6, endname2);
|
else {
|
||||||
memcpy(name, newname, strlen(newname) + 1);
|
char* newname = copy_substring(name + 6, endname2);
|
||||||
tfree(newname);
|
memcpy(name, newname, strlen(newname) + 1);
|
||||||
|
tfree(newname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue