ref: 0a66e143071d423b118e677c5e5b1a8a77a2923b
parent: 547abfefc1bcc45a906329c51f180de703d1ced9
author: Ben10do <[email protected]>
date: Thu Jan 26 13:16:54 EST 2017
Fix division by zero crashes in instructions Previously, rgbasm could crash with a floating point exception if an instruction includes a division or modulo by 0. Fixes #49.
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -316,6 +316,9 @@
struct Expression * src2)
{
joinexpr();
+ if (src2->nVal == 0) {
+ fatalerror("division by zero");
+ }
expr->nVal = (expr->nVal / src2->nVal);
pushbyte(expr, RPN_DIV);
}
@@ -325,6 +328,9 @@
struct Expression * src2)
{
joinexpr();
+ if (src2->nVal == 0) {
+ fatalerror("division by zero");
+ }
expr->nVal = (expr->nVal % src2->nVal);
pushbyte(expr, RPN_MOD);
}