summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-10-15 17:49:18 +0100
committerPaul Evans <leonerd@leonerd.org.uk>2022-10-17 17:54:23 +0100
commitc63def169a29adab9890560dc3e976f9cea37192 (patch)
treece711b781f5fe11231e07c692ea3a74ff55543ad /op.c
parent1537553fc143a3b1c0766f59e887b19396cb2549 (diff)
downloadperl-c63def169a29adab9890560dc3e976f9cea37192.tar.gz
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 )
Diffstat (limited to 'op.c')
-rw-r--r--op.c9
1 files changed, 9 insertions, 0 deletions
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