Corrected an error that allows a variable to be used uninitialized

in parallel_sort, resulting in a (potentially intermittant)
segfault condition.
This commit is contained in:
Tim Edwards 2019-11-19 11:45:49 -05:00
parent f12d03fcff
commit 0e03f0bf97
3 changed files with 15 additions and 5 deletions

View File

@ -3860,6 +3860,7 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
cval = 0.0;
for (i = 0; i < run; i++) {
merge_type = MERGE_NONE;
ml = NULL;
for (p = 0;; p++) {
vl = &(obp->instance.props[p]);
if (vl->type == PROP_ENDLIST) break;
@ -3888,11 +3889,11 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
}
if (merge_type == MERGE_P_ADD) {
proplist[i].value = cval * (double)mval;
ml->value.ival = 1;
if (ml) ml->value.ival = 1;
}
else if (merge_type == MERGE_P_PAR) {
proplist[i].value = cval / (double)mval;
ml->value.ival = 1;
if (ml) ml->value.ival = 1;
}
proplist[i].idx = i;
proplist[i].ob = obp;
@ -3904,6 +3905,7 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
/* and recalculate all the proplist values. */
mval = 1;
obp = obn;
ml = NULL;
merge_type = MERGE_NONE;
for (i = 0; i < run; i++) {
for (p = 0;; p++) {
@ -3935,11 +3937,11 @@ void parallel_sort(struct objlist *ob1, struct nlist *tp1, int idx1, int run)
}
if (merge_type == MERGE_P_ADD) {
proplist[i].value = cval * (double)mval;
ml->value.ival = 1;
if (ml) ml->value.ival = 1;
}
else if (merge_type == MERGE_P_PAR) {
proplist[i].value = cval / (double)mval;
ml->value.ival = 1;
if (ml) ml->value.ival = 1;
}
obp = obp->next;
}

View File

@ -210,6 +210,7 @@ struct hashdict *definitions = (struct hashdict *)NULL;
/*----------------------------------------------------------------------*/
/* TrimQuoted() --- */
/* Remove spaces from inside single- or double-quoted strings. */
/* Ignore verilog constant bits (e.g., "1'b0") when parsing. */
/*----------------------------------------------------------------------*/
void TrimQuoted(char *line)
@ -225,6 +226,13 @@ void TrimQuoted(char *line)
{
changed = FALSE;
qstart = strchr(lptr, '\'');
if (qstart && (qstart > lptr)) {
if (isdigit(*(qstart - 1))) {
lptr = qstart + 1;
changed = TRUE;
continue;
}
}
if (qstart)
{
qend = strchr(qstart + 1, '\'');

View File

@ -634,7 +634,7 @@ void ReadVerilogFile(char *fname, int filenum, struct cellstack **CellStackPtr,
char *paramval = NULL;
// Pick up key = value pairs and store in current cell. Look only
// at the keyword before "=". Then set the defition as everything
// at the keyword before "=". Then set the definition as everything
// remaining in the line, excluding comments, until the end-of-statement
while (nexttok != NULL)