mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-06 22:08:19 +03:00
Guard against division by zero in MOD
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user