diff options
author | Yitzchak Scott-Thoennes <sthoenna@efn.org> | 2006-02-12 17:39:25 -0800 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-02-17 08:50:27 +0000 |
commit | a0cec76945276a0895c829a391529265d9b76bc0 (patch) | |
tree | 071d39c902266f67ba8504374e9785f6c0ce053a /pp.c | |
parent | bc82975d259d743626ad1b4a960b4b1f13c7a816 (diff) | |
download | perl-a0cec76945276a0895c829a391529265d9b76bc0.tar.gz |
Re: [perl #38485] use integer; 0x80000000/-1; # coredump
Message-ID: <20060213093925.GA3476@efn.org>
p4raw-id: //depot/perl@27205
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -2433,9 +2433,12 @@ PP(pp_i_divide) if (value == 0) DIE(aTHX_ "Illegal division by zero"); num = POPi; - if (num == IV_MIN && value == -1) - DIE(aTHX_ "Integer overflow in division"); - value = num / value; + + /* avoid FPE_INTOVF on some platforms when num is IV_MIN */ + if (value == -1) + value = - num; + else + value = num / value; PUSHi( value ); RETURN; } @@ -2450,7 +2453,11 @@ PP(pp_i_modulo_0) dPOPTOPiirl; if (!right) DIE(aTHX_ "Illegal modulus zero"); - SETi( left % right ); + /* avoid FPE_INTOVF on some platforms when left is IV_MIN */ + if (right == -1) + SETi( 0 ); + else + SETi( left % right ); RETURN; } } @@ -2467,7 +2474,11 @@ PP(pp_i_modulo_1) dPOPTOPiirl; if (!right) DIE(aTHX_ "Illegal modulus zero"); - SETi( left % PERL_ABS(right) ); + /* avoid FPE_INTOVF on some platforms when left is IV_MIN */ + if (right == -1) + SETi( 0 ); + else + SETi( left % PERL_ABS(right) ); RETURN; } } @@ -2508,7 +2519,11 @@ PP(pp_i_modulo) } } #endif - SETi( left % right ); + /* avoid FPE_INTOVF on some platforms when left is IV_MIN */ + if (right == -1) + SETi( 0 ); + else + SETi( left % right ); RETURN; } } |