|
|
b8876f |
From 9e5cda6b852ca831004628051cf32c1576146452 Mon Sep 17 00:00:00 2001
|
|
|
b8876f |
From: Father Chrysostomos <sprout@cpan.org>
|
|
|
b8876f |
Date: Thu, 23 Jun 2016 21:57:09 -0700
|
|
|
b8876f |
Subject: [PATCH] [perl #128238] Crash with non-stash in stash
|
|
|
b8876f |
MIME-Version: 1.0
|
|
|
b8876f |
Content-Type: text/plain; charset=UTF-8
|
|
|
b8876f |
Content-Transfer-Encoding: 8bit
|
|
|
b8876f |
|
|
|
b8876f |
This is a follow-up to e7acdfe976f. Even if the name of the stash
|
|
|
b8876f |
entry ends with ::, it may not itself contain a real stash (though
|
|
|
b8876f |
this only happens with code that assigns directly to stash entries,
|
|
|
b8876f |
which has undefined behaviour according to perlmod), so skip hashes
|
|
|
b8876f |
that are not stashes.
|
|
|
b8876f |
|
|
|
b8876f |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
b8876f |
---
|
|
|
b8876f |
gv.c | 4 ++--
|
|
|
b8876f |
t/op/stash.t | 11 +++++++++--
|
|
|
b8876f |
2 files changed, 11 insertions(+), 4 deletions(-)
|
|
|
b8876f |
|
|
|
b8876f |
diff --git a/gv.c b/gv.c
|
|
|
b8876f |
index 2b3bdfa..dff611e 100644
|
|
|
b8876f |
--- a/gv.c
|
|
|
b8876f |
+++ b/gv.c
|
|
|
b8876f |
@@ -2411,10 +2411,10 @@ Perl_gv_check(pTHX_ HV *stash)
|
|
|
b8876f |
|
|
|
b8876f |
PERL_ARGS_ASSERT_GV_CHECK;
|
|
|
b8876f |
|
|
|
b8876f |
- if (!HvARRAY(stash))
|
|
|
b8876f |
+ if (!SvOOK(stash))
|
|
|
b8876f |
return;
|
|
|
b8876f |
|
|
|
b8876f |
- assert(SvOOK(stash));
|
|
|
b8876f |
+ assert(HvARRAY(stash));
|
|
|
b8876f |
|
|
|
b8876f |
for (i = 0; i <= (I32) HvMAX(stash); i++) {
|
|
|
b8876f |
const HE *entry;
|
|
|
b8876f |
diff --git a/t/op/stash.t b/t/op/stash.t
|
|
|
b8876f |
index 1591dbf..fe42700 100644
|
|
|
b8876f |
--- a/t/op/stash.t
|
|
|
b8876f |
+++ b/t/op/stash.t
|
|
|
b8876f |
@@ -7,7 +7,7 @@ BEGIN {
|
|
|
b8876f |
|
|
|
b8876f |
BEGIN { require "./test.pl"; }
|
|
|
b8876f |
|
|
|
b8876f |
-plan( tests => 53 );
|
|
|
b8876f |
+plan( tests => 54 );
|
|
|
b8876f |
|
|
|
b8876f |
# Used to segfault (bug #15479)
|
|
|
b8876f |
fresh_perl_like(
|
|
|
b8876f |
@@ -342,4 +342,11 @@ is runperl(
|
|
|
b8876f |
stderr => 1,
|
|
|
b8876f |
),
|
|
|
b8876f |
"ok\n",
|
|
|
b8876f |
- "[perl #128238] don't treat %: as a stash (needs 2 colons)"
|
|
|
b8876f |
+ "[perl #128238] don't treat %: as a stash (needs 2 colons)";
|
|
|
b8876f |
+
|
|
|
b8876f |
+is runperl(
|
|
|
b8876f |
+ prog => 'BEGIN { $::{q|foo::|}=*ENV; $^W=1}; print qq|ok\n|',
|
|
|
b8876f |
+ stderr => 1,
|
|
|
b8876f |
+ ),
|
|
|
b8876f |
+ "ok\n",
|
|
|
b8876f |
+ "[perl #128238] non-stashes in stashes";
|
|
|
b8876f |
--
|
|
|
b8876f |
2.5.5
|
|
|
b8876f |
|