summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-01-28 23:11:15 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-29 18:11:00 +1200
commit1ca7b98ad174fbe71cdc4e5666d8b6784b21f767 (patch)
tree41a69c47951a7ad14ed58f149e9cc7129cd21e07
parent8a019ce79d3f6edbd72a4f740238e43eaea4945e (diff)
downloadperl-1ca7b98ad174fbe71cdc4e5666d8b6784b21f767.tar.gz
Prevent premature death of @_ during leavesub
-rw-r--r--pp_hot.c5
-rwxr-xr-xt/op/misc.t4
2 files changed, 8 insertions, 1 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 707239fb1b..120c026b4b 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 09385b94a4..25eb6619ed 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';