Skip to content

Commit 2f465e0

Browse files
author
Father Chrysostomos
committed
[perl #123652] eval {label:} crash
As of v5.13.6-130-geae48c8, the block consists solely of a nextstate op. The code in ck_eval that distinguished between eval-block and eval- string was checking the type of the kid op (looking for lineseq or stub) instead of simply checking the type of the op itself (entertry/ entereval). The lexer was already making the distinction between the two but op.c was ignoring the information provided by the lexer. Usually entertry(unop) kid gets converted into leavetry entertry(logop) kid with the entertry reallocated as a larger-sized op, but that was not happening. The peephole optimiser assumed it had happened, and fol- lowed the cLOGOPo->op_other pointer, which is unrelated junk beyond the end of the unop struct. Hence the crash.
1 parent d0500f0 commit 2f465e0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

op.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9671,7 +9671,7 @@ Perl_ck_eval(pTHX_ OP *o)
96719671
SVOP * const kid = (SVOP*)cUNOPo->op_first;
96729672
assert(kid);
96739673

9674-
if (kid->op_type == OP_LINESEQ || kid->op_type == OP_STUB) {
9674+
if (o->op_type == OP_ENTERTRY) {
96759675
LOGOP *enter;
96769676

96779677
/* cut whole sibling chain free from o */

t/comp/parser.t

+3
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,9 @@ $x[FILE1->[0]];
527527
# Used to crash [perl #123542]
528528
eval 's /${<>{}) //';
529529
530+
# Also used to crash [perl #123652]
531+
eval{$1=eval{a:}};
532+
530533
# Add new tests HERE (above this line)
531534
532535
# bug #74022: Loop on characters in \p{OtherIDContinue}

0 commit comments

Comments
 (0)