From 3d8812a2a5ed72332e86e2f36bc5caa37e3e75c0 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 3 Nov 2013 05:49:48 -0800 Subject: [PATCH] Check that stash entries are GVs when aliasing pkgs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit $ perl5.18.1 -e '$Foo::{"Bar::"} = 0; $Bar::Bar::; *Bar:: = *Foo::' Segmentation fault: 11 That $Foo::{"Bar::"} = 0; assignment is documented as having unde- fined behaviour, but it shouldn’t crash. --- mro.c | 2 +- t/mro/package_aliases.t | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mro.c b/mro.c index 18dfa8c..04b3c27 100644 --- a/mro.c +++ b/mro.c @@ -1151,7 +1151,7 @@ S_mro_gather_and_rename(pTHX_ HV * const stashes, HV * const seen_stashes, if( ( - stashentry && *stashentry + stashentry && *stashentry && isGV(*stashentry) && (substash = GvHV(*stashentry)) ) || (oldsubstash && HvENAME_get(oldsubstash)) diff --git a/t/mro/package_aliases.t b/t/mro/package_aliases.t index 34aa2d6..6998a89 100644 --- a/t/mro/package_aliases.t +++ b/t/mro/package_aliases.t @@ -10,7 +10,7 @@ BEGIN { use strict; use warnings; -plan(tests => 53); +plan(tests => 54); { package New; @@ -408,3 +408,11 @@ local *Fooo:: = \%Baro::; no warnings; is 'Bazo'->ber, 'black sheep', 'localised *glob=$stashref assignment'; } + +# $Stash::{"entries::"} that are not globs. +# These used to crash. +$NotGlob::{"NotGlob::"} = 0; () = $NewNotGlob::NotGlob::; +*NewNotGlob:: = *NotGlob::; +pass( + "no crash when clobbering sub-'stash' whose parent stash entry is no GV" +); -- 2.7.4