From: Chip Salzenberg Date: Tue, 28 Jan 1997 11:11:15 +0000 (+1200) Subject: Prevent premature death of @_ during leavesub X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ca7b98ad174fbe71cdc4e5666d8b6784b21f767;p=p5sagit%2Fp5-mst-13.2.git Prevent premature death of @_ during leavesub --- diff --git a/pp_hot.c b/pp_hot.c index 707239f..120c026 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1656,7 +1656,7 @@ PP(pp_leavesub) register CONTEXT *cx; POPBLOCK(cx,newpm); - POPSUB(cx); + /* Delay POPSUB until stack values are safe */ if (gimme == G_SCALAR) { MARK = newsp + 1; @@ -1678,6 +1678,9 @@ PP(pp_leavesub) /* in case LEAVE wipes old return values */ } + /* Now that stack values are safe, release CV and @_ */ + POPSUB(cx); + curpm = newpm; /* Don't pop $1 et al till now */ LEAVE; diff --git a/t/op/misc.t b/t/op/misc.t index 09385b9..25eb661 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -289,3 +289,7 @@ $s = 0; map {#this newline here tickles the bug $s += $_} (1,2,4); print "eat flaming death\n" unless ($s == 7); +######## +sub foo { local $_ = shift; split; @_ } +@x = foo(' x y z '); +print "you die joe!\n" unless "@x" eq 'x y z';