Skip to content

Commit 5d26d78

Browse files
committed
fix size-miscalculation upgrading LISTOP TO LOOPOP
RT #134344 My recent commit v5.31.2-54-g8c47b5bce7 broke some CAN modules because the code in Perl_newFOROP() wasn't accounting for the overhead in the opslot struct when deciding whether an allocated LISTOP was large enough to be upgraded in-place to a LOOPOP.
1 parent 4510b39 commit 5d26d78

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

op.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9287,7 +9287,8 @@ Perl_newFOROP(pTHX_ I32 flags, OP *sv, OP *expr, OP *block, OP *cont)
92879287
/* upgrade loop from a LISTOP to a LOOPOP;
92889288
* keep it in-place if there's space */
92899289
if (loop->op_slabbed
9290-
&& OpSLOT(loop)->opslot_size < SIZE_TO_PSIZE(sizeof(LOOP)))
9290+
&& OpSLOT(loop)->opslot_size
9291+
< SIZE_TO_PSIZE(sizeof(LOOP)) + OPSLOT_HEADER_P)
92919292
{
92929293
/* no space; allocate new op */
92939294
LOOP *tmp;

0 commit comments

Comments
 (0)