Die when integer overflow condition is detected in division under
Steve Peters [Sat, 11 Feb 2006 06:14:02 +0000 (06:14 +0000)]
C<use integer>.  Hopefully fixes RT #38485.

p4raw-id: //depot/perl@27155

pp.c

diff --git a/pp.c b/pp.c
index 3aaad3b..83e0463 100644 (file)
--- 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;
     }