[perl #88138] ' is not equivalent to :: before a null
authorFather Chrysostomos <sprout@cpan.org>
Sat, 4 Jun 2011 04:34:45 +0000 (21:34 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 4 Jun 2011 04:34:45 +0000 (21:34 -0700)
' is usually equivalent to :: in a symbol name. At the *end* of a
symbol name (as in $'), it’s not equivalent. (That’s a feature.)
Perl_gv_fetchpvn_flags was checking for the end by saying
if(next character), which returns false for a null. It should be
checking the length, which it was already doing for ::, and which
this commit makes it do.

gv.c
t/op/stash.t

diff --git a/gv.c b/gv.c
index a003adb..f8de97f 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1064,9 +1064,10 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags,
     }
 
     for (name_cursor = name; name_cursor < name_end; name_cursor++) {
-       if ((*name_cursor == ':' && name_cursor < name_em1
+       if (name_cursor < name_em1 &&
+           ((*name_cursor == ':'
             && name_cursor[1] == ':')
-           || (*name_cursor == '\'' && name_cursor[1]))
+           || *name_cursor == '\''))
        {
            if (!stash)
                stash = PL_defstash;
index 1bd6c70..8132e9d 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
 
 BEGIN { require "./test.pl"; }
 
-plan( tests => 54 );
+plan( tests => 55 );
 
 # Used to segfault (bug #15479)
 fresh_perl_like(
@@ -312,3 +312,7 @@ fresh_perl_is(
     ok eval { Bear::::baz() },
      'packages ending with :: are self-consistent';
 }
+
+# [perl #88138] ' not equivalent to :: before a null
+${"a'\0b"} = "c";
+is ${"a::\0b"}, "c", "' is equivalent to :: before a null";