Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 92e5647

Browse files
Father ChrysostomosReini Urban
authored andcommitted
[perl #128532] Crash vivifying stub in deleted pkg
v5.17.0-515-g186a5ba, which added newSTUB, did not take into account that a GV may have a null GvSTASH pointer, if its stash has been freed, so this crashes: delete $My::{"Foo::"}; \&My::Foo::foo
1 parent ec10bef commit 92e5647

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9603,7 +9603,7 @@ Perl_newSTUB(pTHX_ GV *gv, bool fake)
96039603
assert(!GvCVu(gv));
96049604
GvCV_set(gv, cv);
96059605
GvCVGEN(gv) = 0;
9606-
if (!fake && HvENAME_HEK(GvSTASH(gv)))
9606+
if (!fake && GvSTASH(gv) && HvENAME_HEK(GvSTASH(gv)))
96079607
gv_method_changed(gv);
96089608
if (SvFAKE(gv)) {
96099609
cvgv = gv_fetchsv((SV *)gv, GV_ADDMULTI, SVt_PVCV);

t/op/ref.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BEGIN {
88

99
use strict qw(refs subs);
1010

11-
plan(235);
11+
plan(236);
1212

1313
# Test this first before we extend the stack with other operations.
1414
# This caused an asan failure due to a bad write past the end of the stack.
@@ -124,6 +124,10 @@ is (join(':',@{$spring2{"foo"}}), "1:2:3:4");
124124
is ($called, 1);
125125
}
126126
is ref eval {\&{""}}, "CODE", 'reference to &{""} [perl #94476]';
127+
delete $My::{"Foo::"};
128+
is ref \&My::Foo::foo, "CODE",
129+
'creating stub with \&deleted_stash::foo [perl #128532]';
130+
127131

128132
# Test references to return values of operators (TARGs/PADTMPs)
129133
{

0 commit comments

Comments
 (0)