Corrected an issue where a mismatch in property type (e.g.,

string vs. integer) will cause a segfault.  Not sure if
type promotion is needed at that point because the failing case
was a syntax error that caused a double value to be interpreted
as a string because it could not be cast into a numeric form.
This commit is contained in:
Tim Edwards 2023-10-03 19:39:01 -04:00
parent ce097d5d76
commit f59c9ebcb7
2 changed files with 16 additions and 7 deletions

View File

@ -1 +1 @@
1.5.258
1.5.259

View File

@ -5026,21 +5026,30 @@ int PropertyOptimize(struct objlist *ob, struct nlist *tp, int run, int series,
switch(vl->type) {
case PROP_DOUBLE:
case PROP_VALUE:
dval = 2 * fabs(vl->value.dval - vl2->value.dval)
if ((vl2->type == PROP_DOUBLE) || (vl2->type == PROP_VALUE)) {
dval = 2 * fabs(vl->value.dval - vl2->value.dval)
/ (vl->value.dval + vl2->value.dval);
if (dval <= kl->slop.dval) pmatch++;
if (dval <= kl->slop.dval) pmatch++;
}
break;
case PROP_INTEGER:
ival = abs(vl->value.ival - vl2->value.ival);
if (ival <= kl->slop.ival) pmatch++;
if (vl2->type == PROP_INTEGER) {
ival = abs(vl->value.ival - vl2->value.ival);
if (ival <= kl->slop.ival) pmatch++;
}
break;
case PROP_STRING:
if ((*matchfunc)(vl->value.string, vl2->value.string)) pmatch++;
if (vl2->type == PROP_STRING) {
if ((*matchfunc)(vl->value.string, vl2->value.string)) pmatch++;
}
break;
/* will not attempt to match expressions, but it could
/* Will not attempt to match expressions, but it could
* be done with some minor effort by matching each
* stack token and comparing those that are strings.
* Likewise, will not attempt to match properties
* whose types are mismatched, but they could be
* promoted here.
*/
}
}