Blame SOURCES/perl-5.25.2-perl-128532-Crash-vivifying-stub-in-deleted-pkg.patch

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