ref: a3e95f99d2da1597feffe0fe1db8531197e86f59
parent: e3a31d7e593ced6606055c720c4269cb7cb5e2d0
author: Anthony J. Bentley <[email protected]>
date: Mon Jan 26 23:56:42 EST 2015
rgbasm: Fix a division by zero in section address specifiers.
--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -992,8 +992,16 @@
| const T_OP_SHL const { $$ = $1 << $3; }
| const T_OP_SHR const { $$ = $1 >> $3; }
| const T_OP_MUL const { $$ = $1 * $3; }
- | const T_OP_DIV const { $$ = $1 / $3; }
- | const T_OP_MOD const { $$ = $1 % $3; }
+ | const T_OP_DIV const {
+ if ($3 == 0)
+ fatalerror("division by zero");
+ $$ = $1 / $3;
+ }
+ | const T_OP_MOD const {
+ if ($3 == 0)
+ fatalerror("division by zero");
+ $$ = $1 % 3;
+ }
| T_OP_ADD const %prec NEG { $$ = +$2; }
| T_OP_SUB const %prec NEG { $$ = -$2; }
| T_OP_NOT const %prec NEG { $$ = 0xFFFFFFFF^$2; }