changeset 250:644f8abf87dc

Apply division by zero fix to modulus operator too. Modulus is also division. It also needs protection against division by zero.
author William Astle <lost@l-w.ca>
date Fri, 25 Jan 2013 21:54:02 -0700
parents 1f1a28b797e1
children 0e4a9b21ad7b
files lwlib/lw_expr.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/lw_expr.c	Fri Jan 25 21:48:01 2013 -0700
+++ b/lwlib/lw_expr.c	Fri Jan 25 21:54:02 2013 -0700
@@ -744,6 +744,12 @@
 			break;
 		
 		case lw_expr_oper_mod:
+			if (E -> operands -> next -> p -> value == 0)
+			{
+				tr = 0;
+				lw_expr_divzero(priv);
+				break;
+			}
 			tr = E -> operands -> p -> value % E -> operands -> next -> p -> value;
 			break;