[qfcc] Count terms correctly

Parentheses confused the term counting because they weren't taken into
account for the "neither expression can be split" check, resulting in a
later segfault due to walking off the end of the array.
This commit is contained in:
Bill Currie 2025-01-18 20:47:06 +09:00
parent 7dc1ab0ea8
commit df04a37a8c

View file

@ -454,7 +454,7 @@ count_terms (const expr_t *expr)
}
auto e1 = expr->expr.e1;
auto e2 = expr->expr.e2;
int terms = !is_sum (e1) + !is_sum (e2);
int terms = (!is_sum (e1) || e1->paren) + (!is_sum (e2) || e2->paren);
if (!e1->paren && is_sum (e1)) {
terms += count_terms (expr->expr.e1);
}