shithub: rgbds

Download patch

ref: d6cd5823e3053bbcf356715e3a4933aa6f94c6f0
parent: f9f27d6f5a00898f7d3faaee921ab8d13e13b85a
parent: 5dd941b311ea5a4d0e873ad0b6a1a0db9ed2aedc
author: Eldred Habert <[email protected]>
date: Thu Apr 9 10:52:12 EDT 2020

Merge pull request #508 from JL2210/mod-by-zero-fix-2

Fix modulo by zero

--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -185,7 +185,13 @@
 			break;
 		case RPN_MOD:
 			value = popRPN();
-			value = popRPN() % value;
+			if (value == 0) {
+				error("%s: Modulo by 0", patch->fileName);
+				popRPN();
+				value = 0;
+			} else {
+				value = popRPN() % value;
+			}
 			break;
 		case RPN_UNSUB:
 			value = -popRPN();