From: Steve Peters Date: Sat, 11 Feb 2006 06:14:02 +0000 (+0000) Subject: Die when integer overflow condition is detected in division under X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ece1bcefc6e1d5c666cb173e3db4fb5c6663a8b9;p=p5sagit%2Fp5-mst-13.2.git Die when integer overflow condition is detected in division under C. Hopefully fixes RT #38485. p4raw-id: //depot/perl@27155 --- diff --git a/pp.c b/pp.c index 3aaad3b..83e0463 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; }