Prevent a crash if hash model table was not generated,

e.g. due to missing valid models.
This commit is contained in:
Holger Vogt 2023-10-27 23:13:41 +02:00
parent ce82c839e3
commit efdf332061
1 changed files with 22 additions and 20 deletions

View File

@ -343,31 +343,33 @@ INPgetMod(CKTcircuit *ckt, char *name, INPmodel **model, INPtables *tab)
printf("In INPgetMod, examining model %s ...\n", name);
#endif
modtmp = nghash_find(modtabhash, name);
if (modtmp) {
/* found the model in question - now instantiate if necessary */
/* and return an appropriate pointer to it */
if (modtabhash) {
modtmp = nghash_find(modtabhash, name);
if (modtmp) {
/* found the model in question - now instantiate if necessary */
/* and return an appropriate pointer to it */
/* if illegal device type */
if (modtmp->INPmodType < 0) {
/* if illegal device type */
if (modtmp->INPmodType < 0) {
#ifdef TRACE
printf("In INPgetMod, illegal device type for model %s ...\n", name);
printf("In INPgetMod, illegal device type for model %s ...\n", name);
#endif
* model = NULL;
return tprintf("Unknown device type for model %s\n", name);
}
/* create unless model is already defined */
if (!modtmp->INPmodfast) {
int error = create_model(ckt, modtmp, tab);
if (error) {
*model = NULL;
return INPerror(error);
* model = NULL;
return tprintf("Unknown device type for model %s\n", name);
}
}
*model = modtmp;
return NULL;
/* create unless model is already defined */
if (!modtmp->INPmodfast) {
int error = create_model(ckt, modtmp, tab);
if (error) {
*model = NULL;
return INPerror(error);
}
}
*model = modtmp;
return NULL;
}
}
#if (0)
for (modtmp = modtab; modtmp; modtmp = modtmp->INPnextModel) {