Skip to content

Commit bc675a2

Browse files
committed
chop/chomp: avoid signed integer overflow
Fixes Coverity CID 584015 ("underflow: The cast of count to a signed type could result in a negative number").
1 parent b9576c1 commit bc675a2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ PP(pp_schop)
901901

902902
const size_t count = do_chomp(TARG, *PL_stack_sp, chomping);
903903
if (chomping)
904-
sv_setiv(TARG, (IV)count);
904+
sv_setuv(TARG, count);
905905
SvSETMAGIC(TARG);
906906
rpp_replace_1_1_NN(TARG);
907907
return NORMAL;
@@ -919,7 +919,7 @@ PP_wrapped(pp_chop, 0, 1)
919919
while (MARK < SP)
920920
count += do_chomp(TARG, *++MARK, chomping);
921921
if (chomping)
922-
sv_setiv(TARG, count);
922+
sv_setuv(TARG, count);
923923
SP = ORIGMARK;
924924
XPUSHTARG;
925925
RETURN;

0 commit comments

Comments
 (0)