comparison 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
comparison
equal deleted inserted replaced
582:1ede8f8621cf 583:000381ee2d5c
512 512
513 // e1 is not a times 513 // e1 is not a times
514 if (e2 -> type == lw_expr_type_oper && e2 -> value == lw_expr_oper_times) 514 if (e2 -> type == lw_expr_type_oper && e2 -> value == lw_expr_oper_times)
515 { 515 {
516 // e2 is a times 516 // e2 is a times
517 if (!(e2 -> operands -> next))
518 return 0; // if there aren't at least two operands
517 if (e2 -> operands -> next -> next) 519 if (e2 -> operands -> next -> next)
518 return 0; 520 return 0; // if there is more than one operand
519 if (!lw_expr_compare(e1, e2 -> operands -> next -> p)) 521 if (!lw_expr_compare(e1, e2 -> operands -> next -> p))
520 return 0; 522 return 0;
521 return 1; 523 return 1;
522 } 524 }
523 525