mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
throw ArithmeticException on divide-by-zero
This commit is contained in:
@ -1665,6 +1665,11 @@ interpret(Thread* t)
|
||||
case idiv: {
|
||||
int32_t b = popInt(t);
|
||||
int32_t a = popInt(t);
|
||||
|
||||
if (UNLIKELY(b == 0)) {
|
||||
exception = makeThrowable(t, Machine::ArithmeticExceptionType);
|
||||
goto throw_;
|
||||
}
|
||||
|
||||
pushInt(t, a / b);
|
||||
} goto loop;
|
||||
@ -1968,6 +1973,11 @@ interpret(Thread* t)
|
||||
int32_t b = popInt(t);
|
||||
int32_t a = popInt(t);
|
||||
|
||||
if (UNLIKELY(b == 0)) {
|
||||
exception = makeThrowable(t, Machine::ArithmeticExceptionType);
|
||||
goto throw_;
|
||||
}
|
||||
|
||||
pushInt(t, a % b);
|
||||
} goto loop;
|
||||
|
||||
@ -2187,6 +2197,11 @@ interpret(Thread* t)
|
||||
int64_t b = popLong(t);
|
||||
int64_t a = popLong(t);
|
||||
|
||||
if (UNLIKELY(b == 0)) {
|
||||
exception = makeThrowable(t, Machine::ArithmeticExceptionType);
|
||||
goto throw_;
|
||||
}
|
||||
|
||||
pushLong(t, a / b);
|
||||
} goto loop;
|
||||
|
||||
@ -2269,6 +2284,11 @@ interpret(Thread* t)
|
||||
int64_t b = popLong(t);
|
||||
int64_t a = popLong(t);
|
||||
|
||||
if (UNLIKELY(b == 0)) {
|
||||
exception = makeThrowable(t, Machine::ArithmeticExceptionType);
|
||||
goto throw_;
|
||||
}
|
||||
|
||||
pushLong(t, a % b);
|
||||
} goto loop;
|
||||
|
||||
|
Reference in New Issue
Block a user