summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-06-24 20:16:30 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-07-25 23:48:00 -0700
commit706a6ebcf667fec4e1457b7ad601645a3aaa7764 (patch)
treec28ae8a92b0a6665e51a01ffe65ba3c6cdcb7263 /pp.c
parent2484f8dbbb584bb7bc7107e23ebd49f694eb3ea2 (diff)
downloadperl-706a6ebcf667fec4e1457b7ad601645a3aaa7764.tar.gz
[perl #78194] Make list slices copy PADTMPs in lv cx
So that slices that reference the same value multiple times (such as (...)[1,1]) will exhibit referential identity (\(...)[1,1] will return two references to the same scalar).
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index cadfe96371..99f7d1fa07 100644
--- a/pp.c
+++ b/pp.c
@@ -4773,6 +4773,7 @@ PP(pp_lslice)
SV ** const firstlelem = PL_stack_base + POPMARK + 1;
SV ** const firstrelem = lastlelem + 1;
I32 is_something_there = FALSE;
+ const U8 mod = PL_op->op_flags & OPf_MOD;
const I32 max = lastrelem - lastlelem;
SV **lelem;
@@ -4804,6 +4805,8 @@ PP(pp_lslice)
is_something_there = TRUE;
if (!(*lelem = firstrelem[ix]))
*lelem = &PL_sv_undef;
+ else if (mod && SvPADTMP(*lelem) && !IS_PADGV(*lelem))
+ *lelem = firstrelem[ix] = sv_mortalcopy(*lelem);
}
}
if (is_something_there)