summaryrefslogtreecommitdiff
path: root/t/cmd
diff options
context:
space:
mode:
authorPeter Martini <PeterCMartini@GMail.com>2013-03-03 00:09:58 +0000
committerDavid Mitchell <davem@iabyn.com>2013-03-03 00:25:13 +0000
commit89e006ae4e39db68ad35c878eb6e6de83ebd8ec9 (patch)
tree0b1dd9aff102daa5cbff60b5fad1d8a0ab848bdd /t/cmd
parenta429ddf7a2c14de7caaf9248c6a79212167468f9 (diff)
downloadperl-89e006ae4e39db68ad35c878eb6e6de83ebd8ec9.tar.gz
Stop SEGV on 'our sub { syntax error }'
Fix for RT #116981. If a sub is declared with our, the name is added to the stash early, and left with a NULL ptr if there's a syntax error while compiling it. Since the only time it becomes an issue is when that same name is used in the same scope after a syntax error, what happens in the pad is not particularly important. The simple fix is to simply fall back to treating it like a bareword, and pretending it was never added to the pad in the first place.
Diffstat (limited to 't/cmd')
-rw-r--r--t/cmd/lexsub.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/t/cmd/lexsub.t b/t/cmd/lexsub.t
index 86c7e26a14..46bab038fd 100644
--- a/t/cmd/lexsub.t
+++ b/t/cmd/lexsub.t
@@ -8,7 +8,7 @@ BEGIN {
*bar::like = *like;
}
no warnings 'deprecated';
-plan 128;
+BEGIN{plan 133;}
# -------------------- Errors with feature disabled -------------------- #
@@ -95,6 +95,19 @@ sub bar::c { 43 }
my $y = if if if;
is $y, 42, 'our subs from other packages override all keywords';
}
+# Make sure errors don't pollute the stash (see RT 116981)
+{
+ eval "our sub ln99{!} ln99(1)";
+ eval "ln99(1)";
+ like $@, "Undefined subroutine &main::ln99 called", "Bad definitions do not pollute the stash";
+ isnt $::{ln99}, -1, "No placeholder was entered";
+ our sub ln103;
+ is $::{ln103}, -1, "Placeholder was entered";
+ eval "our sub ln103{!} ln103(1)";
+ eval "ln103(1)";
+ like $@, "Undefined subroutine &main::ln103 called", "Bad definitions do not pollute the stash";
+ isnt $::{ln103}, -1, "Placeholder was removed";
+}
# -------------------- state -------------------- #