From c63def169a29adab9890560dc3e976f9cea37192 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 15 Oct 2022 17:49:18 +0100 Subject: Don't set OPf_REF on OP_ANONCODE during op_lvalue() Doing so will upset XS code that manually builds optrees using OP_REFGEN + OP_ANONCODE (as would be required prior to perl 5.37.3), causing a double-reference to be generated. (Fixes https://github.com/Perl/perl5/issues/20384 ) --- op.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'op.c') diff --git a/op.c b/op.c index f3f367f5ed..e6b5842e7f 100644 --- a/op.c +++ b/op.c @@ -3444,6 +3444,15 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags) case OP_SCALAR: op_lvalue(cUNOPo->op_first, OP_ENTERSUB); goto nomod; + + case OP_ANONCODE: + /* If we were to set OPf_REF on this and it was constructed by XS + * code as a child of an OP_REFGEN then we'd end up generating a + * double-ref when executed. We don't want to do that, so don't + * set flag here. + * See also https://github.com/Perl/perl5/issues/20384 + */ + goto do_next; } /* [20011101.069 (#7861)] File test operators interpret OPf_REF to mean that -- cgit v1.2.1