From 658aef798ab992aed2b708fed0d12323ab3b1fcb Mon Sep 17 00:00:00 2001 From: Dave Mitchell Date: Thu, 27 Apr 2006 23:15:02 +0000 Subject: [PATCH] [perl #39012] another REIFY bug p4raw-id: //depot/perl@27986 --- scope.c | 2 +- t/op/local.t | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scope.c b/scope.c index 33763a7..8e40e8e 100644 --- a/scope.c +++ b/scope.c @@ -845,9 +845,9 @@ Perl_leave_scope(pTHX_ I32 base) value = (SV*)SSPOPPTR; i = SSPOPINT; av = (AV*)SSPOPPTR; + ptr = av_fetch(av,i,1); if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */ SvREFCNT_dec(value); - ptr = av_fetch(av,i,1); if (ptr) { sv = *(SV**)ptr; if (sv && sv != &PL_sv_undef) { diff --git a/t/op/local.t b/t/op/local.t index ca44607..1e5ba85 100755 --- a/t/op/local.t +++ b/t/op/local.t @@ -4,7 +4,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; } -plan tests => 113; +plan tests => 114; my $list_assignment_supported = 1; @@ -415,3 +415,15 @@ sub f { ok(0 == $[); } is($h{"\243"}, "pound"); is($h{"\302\240"}, "octects"); } + +# [perl #39012] localizing @_ element then shifting frees element too # soon + +{ + my $x; + my $y = bless [], 'X39012'; + sub X39012::DESTROY { $x++ } + sub { local $_[0]; shift }->($y); + ok(!$x, '[perl #39012]'); + +} + -- 2.7.4