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.
This commit is contained in:
Lukas Mai 2025-08-18 22:39:53 +02:00
parent d002288880
commit d9affba121

View File

@ -5123,7 +5123,7 @@ PP_wrapped(pp_sleep, MAXARG, 0)
if (MAXARG < 1 || (!TOPs && !POPs))
PerlProc_pause();
else {
const I32 duration = POPi;
const IV duration = POPi;
if (duration < 0) {
/* diag_listed_as: %s() with negative argument */
ck_warner_d(packWARN(WARN_MISC),