In perl.git, the branch sprout/mstack has been updated <http://perl5.git.perl.org/perl.git/commitdiff/0169b0ac35d88f8b0dbcf9aabb87679899b2631b?hp=2d5941272b93560486a3e7387adeb9b1e683b323>
- Log ----------------------------------------------------------------- commit 0169b0ac35d88f8b0dbcf9aabb87679899b2631b Author: Father Chrysostomos <spr...@cpan.org> Date: Wed Aug 10 23:59:07 2016 -0700 [perl #24342] Mortalize elems in array slice ----------------------------------------------------------------------- Summary of changes: pp.c | 2 +- t/op/stack.t | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pp.c b/pp.c index fff0826..4b93861 100644 --- a/pp.c +++ b/pp.c @@ -4692,7 +4692,7 @@ PP(pp_aslice) SAVEADELETE(av, elem); } } - *MARK = svp ? *svp : &PL_sv_undef; + *MARK = svp ? SvREFCNT_inc_NN(sv_2mortal(*svp)) : &PL_sv_undef; } } if (GIMME_V != G_ARRAY) { diff --git a/t/op/stack.t b/t/op/stack.t index 6026228..be158aa 100644 --- a/t/op/stack.t +++ b/t/op/stack.t @@ -8,7 +8,7 @@ BEGIN { use strict; -plan 5; +plan 6; my @a = ( 'abc', 'def', 'ghi' ); @a = map { splice( @a, 0 ); $_ } ( @a ); @@ -39,3 +39,9 @@ is $@, '', '[perl #18489] freeing elems of sort @pkg_array'; map{@a=($_+=0)x$_}@a=qw(1 1); pass '[perl #22312] map freeing elems from array assignment'; + +our @F; +$F[7] = 8; +$a=@F[4,7]-=@F=3; +is $a, 7, + '[perl #24342] array assignment freeing stack elem from array slice'; -- Perl5 Master Repository