summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2006-02-11 06:14:02 +0000
committerSteve Peters <steve@fisharerojo.org>2006-02-11 06:14:02 +0000
commitece1bcefc6e1d5c666cb173e3db4fb5c6663a8b9 (patch)
tree52cbcc6b0ed232c1281c56ab8e01dcd661a57a71 /pp.c
parentc2b4a044213bea86e9e2d063d8cade83f2b9aa8b (diff)
downloadperl-ece1bcefc6e1d5c666cb173e3db4fb5c6663a8b9.tar.gz
Die when integer overflow condition is detected in division under
C<use integer>. Hopefully fixes RT #38485. p4raw-id: //depot/perl@27155
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pp.c b/pp.c
index 3aaad3b4bd..83e0463abb 100644
--- a/pp.c
+++ b/pp.c
@@ -2423,12 +2423,16 @@ PP(pp_i_multiply)
PP(pp_i_divide)
{
+ IV num;
dVAR; dSP; dATARGET; tryAMAGICbin(div,opASSIGN);
{
dPOPiv;
if (value == 0)
- DIE(aTHX_ "Illegal division by zero");
- value = POPi / value;
+ DIE(aTHX_ "Illegal division by zero");
+ num = POPi;
+ if (num == IV_MIN && value == -1)
+ DIE(aTHX_ "Integer overflow in division");
+ value = num / value;
PUSHi( value );
RETURN;
}