From: Father Chrysostomos Date: Sun, 3 Nov 2013 13:49:48 +0000 (-0800) Subject: Check that stash entries are GVs when aliasing pkgs X-Git-Tag: upstream/5.20.0~1380 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d8812a2a5ed72332e86e2f36bc5caa37e3e75c0;p=platform%2Fupstream%2Fperl.git Check that stash entries are GVs when aliasing pkgs $ 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. --- 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" +);