Corrected two statements that can cause a segfault because a

structure variable is not checked for the condition of being NULL
before attempting to read a component of the structure.  These
conditions imply that something is badly wrong in the netlist but
should not be causing a segfault.
This commit is contained in:
Tim Edwards 2024-05-16 11:49:56 -04:00
parent fcee934580
commit bf4112db07
2 changed files with 3 additions and 3 deletions

View File

@ -1 +1 @@
1.5.275 1.5.276

View File

@ -3094,7 +3094,7 @@ void add_balancing_close(struct objlist *ob1, struct objlist *ob2)
for (nob = ob1->next; nob && nob->type != FIRSTPIN; nob = nob->next) for (nob = ob1->next; nob && nob->type != FIRSTPIN; nob = nob->next)
if (nob->type == PROPERTY) if (nob->type == PROPERTY)
break; break;
if (nob->type != PROPERTY) return; // shouldn't happen if (nob == NULL || nob->type != PROPERTY) return; // shouldn't happen
opentags = 0; opentags = 0;
for (; nob->next && nob->next->type == PROPERTY; nob = nob->next) { for (; nob->next && nob->next->type == PROPERTY; nob = nob->next) {
@ -3644,7 +3644,7 @@ int CombineSeries(char *model, int file)
nob->type = PROPERTY; nob->type = PROPERTY;
nob->name = strsave("properties"); nob->name = strsave("properties");
nob->node = -2; /* Don't report as disconnected node */ nob->node = -2; /* Don't report as disconnected node */
nob->model.class = (obp->model.class == NULL) ? NULL : nob->model.class = (obp == NULL || obp->model.class == NULL) ? NULL :
strsave(obp->model.class); strsave(obp->model.class);
nob->instance.props = NewPropValue(2); nob->instance.props = NewPropValue(2);