This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #112316] Make strict vars respect assignment to null pkg
authorFather Chrysostomos <sprout@cpan.org>
Sun, 8 Apr 2012 21:51:57 +0000 (14:51 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 20 Apr 2012 03:09:11 +0000 (20:09 -0700)
Under threads, strict vars was not respecting assignment to a package
with a null in its name if the name of the package assigned from was
equal to the prefix of the destination package up to the null.

t/lib/strict/vars
util.c

index fdd7af3..28aab48 100644 (file)
@@ -536,3 +536,12 @@ use strict 'vars';
 no warnings;
 eval q/$dweck/;
 EXPECT
+########
+# [perl #112316] strict vars getting confused by nulls
+# Assigning to a package whose name contains a null
+BEGIN { *Foo:: = *{"foo\0bar::"} }
+package foo;
+*Foo::bar = [];
+use strict;
+eval 'package Foo; @bar = 1' or die;
+EXPECT
diff --git a/util.c b/util.c
index d147e9e..cba3c7b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -5872,7 +5872,8 @@ Perl_stashpv_hvname_match(pTHX_ const COP *c, const HV *hv)
     }
     else
         return (stashpv == name
-                    || strEQ(stashpv, name));
+                    || ((STRLEN)HEK_LEN(HvNAME_HEK(hv)) == strlen(stashpv)
+                        && strEQ(stashpv, name)));
     /*NOTREACHED*/
     return FALSE;
 }