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:
parent
ce097d5d76
commit
f59c9ebcb7
|
|
@ -5026,21 +5026,30 @@ int PropertyOptimize(struct objlist *ob, struct nlist *tp, int run, int series,
|
||||||
switch(vl->type) {
|
switch(vl->type) {
|
||||||
case PROP_DOUBLE:
|
case PROP_DOUBLE:
|
||||||
case PROP_VALUE:
|
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);
|
/ (vl->value.dval + vl2->value.dval);
|
||||||
if (dval <= kl->slop.dval) pmatch++;
|
if (dval <= kl->slop.dval) pmatch++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_INTEGER:
|
case PROP_INTEGER:
|
||||||
ival = abs(vl->value.ival - vl2->value.ival);
|
if (vl2->type == PROP_INTEGER) {
|
||||||
if (ival <= kl->slop.ival) pmatch++;
|
ival = abs(vl->value.ival - vl2->value.ival);
|
||||||
|
if (ival <= kl->slop.ival) pmatch++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_STRING:
|
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;
|
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
|
* be done with some minor effort by matching each
|
||||||
* stack token and comparing those that are strings.
|
* 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.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue