|
|
b8876f |
From 63aab7ecaa6e826f845c405894bd8c4b6f601b39 Mon Sep 17 00:00:00 2001
|
|
|
b8876f |
From: Father Chrysostomos <sprout@cpan.org>
|
|
|
b8876f |
Date: Sun, 3 Jul 2016 22:23:34 -0700
|
|
|
b8876f |
Subject: [PATCH] [perl #128532] Crash vivifying stub in deleted pkg
|
|
|
b8876f |
MIME-Version: 1.0
|
|
|
b8876f |
Content-Type: text/plain; charset=UTF-8
|
|
|
b8876f |
Content-Transfer-Encoding: 8bit
|
|
|
b8876f |
|
|
|
b8876f |
v5.17.0-515-g186a5ba, which added newSTUB, did not take into account
|
|
|
b8876f |
that a GV may have a null GvSTASH pointer, if its stash has been
|
|
|
b8876f |
freed, so this crashes:
|
|
|
b8876f |
|
|
|
b8876f |
delete $My::{"Foo::"}; \&My::Foo::foo
|
|
|
b8876f |
|
|
|
b8876f |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
b8876f |
---
|
|
|
b8876f |
op.c | 2 +-
|
|
|
b8876f |
t/op/ref.t | 6 +++++-
|
|
|
b8876f |
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
|
b8876f |
|
|
|
b8876f |
diff --git a/op.c b/op.c
|
|
|
b8876f |
index 46e76ac..4735d1b 100644
|
|
|
b8876f |
--- a/op.c
|
|
|
b8876f |
+++ b/op.c
|
|
|
b8876f |
@@ -9081,7 +9081,7 @@ Perl_newSTUB(pTHX_ GV *gv, bool fake)
|
|
|
b8876f |
assert(!GvCVu(gv));
|
|
|
b8876f |
GvCV_set(gv, cv);
|
|
|
b8876f |
GvCVGEN(gv) = 0;
|
|
|
b8876f |
- if (!fake && HvENAME_HEK(GvSTASH(gv)))
|
|
|
b8876f |
+ if (!fake && GvSTASH(gv) && HvENAME_HEK(GvSTASH(gv)))
|
|
|
b8876f |
gv_method_changed(gv);
|
|
|
b8876f |
if (SvFAKE(gv)) {
|
|
|
b8876f |
cvgv = gv_fetchsv((SV *)gv, GV_ADDMULTI, SVt_PVCV);
|
|
|
b8876f |
diff --git a/t/op/ref.t b/t/op/ref.t
|
|
|
b8876f |
index 19a44bb..84d9217 100644
|
|
|
b8876f |
--- a/t/op/ref.t
|
|
|
b8876f |
+++ b/t/op/ref.t
|
|
|
b8876f |
@@ -8,7 +8,7 @@ BEGIN {
|
|
|
b8876f |
|
|
|
b8876f |
use strict qw(refs subs);
|
|
|
b8876f |
|
|
|
b8876f |
-plan(235);
|
|
|
b8876f |
+plan(236);
|
|
|
b8876f |
|
|
|
b8876f |
# Test this first before we extend the stack with other operations.
|
|
|
b8876f |
# This caused an asan failure due to a bad write past the end of the stack.
|
|
|
b8876f |
@@ -124,6 +124,10 @@ is (join(':',@{$spring2{"foo"}}), "1:2:3:4");
|
|
|
b8876f |
is ($called, 1);
|
|
|
b8876f |
}
|
|
|
b8876f |
is ref eval {\&{""}}, "CODE", 'reference to &{""} [perl #94476]';
|
|
|
b8876f |
+delete $My::{"Foo::"};
|
|
|
b8876f |
+is ref \&My::Foo::foo, "CODE",
|
|
|
b8876f |
+ 'creating stub with \&deleted_stash::foo [perl #128532]';
|
|
|
b8876f |
+
|
|
|
b8876f |
|
|
|
b8876f |
# Test references to return values of operators (TARGs/PADTMPs)
|
|
|
b8876f |
{
|
|
|
b8876f |
--
|
|
|
b8876f |
2.5.5
|
|
|
b8876f |
|