Guard against division by zero in MOD

This commit is contained in:
Nunuhara Cabbage
2022-04-10 09:02:30 -07:00
parent eca92c4f7e
commit 75bb6d1e43
+5 -1
View File
@@ -1000,7 +1000,11 @@ static enum opcode execute_instruction(enum opcode opcode)
break;
}
case MOD: {
stack[stack_ptr-2].i %= stack[stack_ptr-1].i;
if (!stack[stack_ptr-1].i) {
stack[stack_ptr-2].i = 0;
} else {
stack[stack_ptr-2].i %= stack[stack_ptr-1].i;
}
stack_ptr--;
break;
}