In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/89e006ae4e39db68ad35c878eb6e6de83ebd8ec9?hp=a429ddf7a2c14de7caaf9248c6a79212167468f9>

- Log -----------------------------------------------------------------
commit 89e006ae4e39db68ad35c878eb6e6de83ebd8ec9
Author: Peter Martini <[email protected]>
Date:   Sun Mar 3 00:09:58 2013 +0000

    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.
-----------------------------------------------------------------------

Summary of changes:
 t/cmd/lexsub.t |   15 ++++++++++++++-
 toke.c         |    5 +++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/t/cmd/lexsub.t b/t/cmd/lexsub.t
index 86c7e26..46bab03 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 -------------------- #
 
diff --git a/toke.c b/toke.c
index aace60b..006f885 100644
--- a/toke.c
+++ b/toke.c
@@ -6900,6 +6900,11 @@ Perl_yylex(pTHX)
                    gv = gv_fetchsv(sv, GV_NOADD_NOINIT | SvUTF8(sv),
                                    SVt_PVCV);
                    off = 0;
+                   if (!gv) {
+                       sv_free(sv);
+                       sv = NULL;
+                       goto just_a_word;
+                   }
                }
                else {
                    rv2cv_op = newOP(OP_PADANY, 0);

--
Perl5 Master Repository

Reply via email to