From a3e95f99d2da1597feffe0fe1db8531197e86f59 Mon Sep 17 00:00:00 2001 From: "Anthony J. Bentley" Date: Tue, 27 Jan 2015 04:56:42 -0700 Subject: [PATCH] rgbasm: Fix a division by zero in section address specifiers. --- src/asm/asmy.y | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/asm/asmy.y b/src/asm/asmy.y index d5816b5d..e34d0047 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -992,8 +992,16 @@ const : T_ID { $$ = sym_GetConstantValue($1); } | 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; }