Mercurial > hg > index.cgi
diff lwlib/lw_expr.c @ 583:000381ee2d5c default tip
Guard against single operand multiplication when detecting like terms
This *shouldn't* happen, but it apparently does in some pathological cases
so guard against a single operand multiplication to prevent a crash.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 04 Nov 2024 23:48:23 -0700 |
parents | 052c5f335a92 |
children |
line wrap: on
line diff
--- a/lwlib/lw_expr.c Thu Aug 08 13:46:19 2024 -0600 +++ b/lwlib/lw_expr.c Mon Nov 04 23:48:23 2024 -0700 @@ -514,8 +514,10 @@ if (e2 -> type == lw_expr_type_oper && e2 -> value == lw_expr_oper_times) { // e2 is a times + if (!(e2 -> operands -> next)) + return 0; // if there aren't at least two operands if (e2 -> operands -> next -> next) - return 0; + return 0; // if there is more than one operand if (!lw_expr_compare(e1, e2 -> operands -> next -> p)) return 0; return 1;