mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Prevent floating-point exception if we evaluate $IntMin * (-1)
This commit is contained in:
@@ -940,6 +940,11 @@ static int Multiply(void)
|
||||
}
|
||||
|
||||
if (v1.type == INT_TYPE && v2.type == INT_TYPE) {
|
||||
/* Prevent floating-point exception */
|
||||
if ((v2.v.val == -1 && v1.v.val == INT_MIN) ||
|
||||
(v1.v.val == -1 && v2.v.val == INT_MIN)) {
|
||||
return E_2HIGH;
|
||||
}
|
||||
int old = v1.v.val;
|
||||
v1.v.val *= v2.v.val;
|
||||
if (v2.v.val != 0) {
|
||||
|
||||
@@ -3117,10 +3117,20 @@ $IntMin => -2147483648
|
||||
- 1 => -1
|
||||
-2147483648 / -1 => Number too high
|
||||
../tests/test.rem(553): `/': Number too high
|
||||
set a $IntMin * (-1)
|
||||
$IntMin => -2147483648
|
||||
- 1 => -1
|
||||
-2147483648 * -1 => Number too high
|
||||
../tests/test.rem(554): `*': Number too high
|
||||
set a (-1) * $IntMin
|
||||
- 1 => -1
|
||||
$IntMin => -2147483648
|
||||
-1 * -2147483648 => Number too high
|
||||
../tests/test.rem(555): `*': Number too high
|
||||
set a abs($IntMin)
|
||||
$IntMin => -2147483648
|
||||
abs(-2147483648) => Number too high
|
||||
../tests/test.rem(554): Number too high
|
||||
../tests/test.rem(556): Number too high
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
@@ -551,6 +551,8 @@ set a $IntMin * 2
|
||||
set a $IntMin * $IntMin
|
||||
set a $IntMin * $IntMax
|
||||
set a $IntMin / (-1)
|
||||
set a $IntMin * (-1)
|
||||
set a (-1) * $IntMin
|
||||
set a abs($IntMin)
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
|
||||
Reference in New Issue
Block a user