Skip to content

Commit d9affba

Browse files
committed
pp_sleep: fix potential I32 overflow
Coverity says: CID 584095: Integer handling issues (INTEGER_OVERFLOW) Expression "duration", where "(IV)Perl_SvIV(my_perl, *sp--)" is known to be equal to 0, overflows the type of "duration", which is type "I32 const". There are two dodgy type conversions in this function: from IV (POPi) to I32 (duration), and from I32 (duration) to unsigned int (sleep argument, by cast). Avoid the one Coverity complains about by making 'duration' an IV.
1 parent d002288 commit d9affba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pp_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5123,7 +5123,7 @@ PP_wrapped(pp_sleep, MAXARG, 0)
51235123
if (MAXARG < 1 || (!TOPs && !POPs))
51245124
PerlProc_pause();
51255125
else {
5126-
const I32 duration = POPi;
5126+
const IV duration = POPi;
51275127
if (duration < 0) {
51285128
/* diag_listed_as: %s() with negative argument */
51295129
ck_warner_d(packWARN(WARN_MISC),

0 commit comments

Comments
 (0)