diff --git a/gv.c b/gv.c index 96301ff15107..b1bc60f4e652 100644 --- a/gv.c +++ b/gv.c @@ -959,8 +959,9 @@ Perl_gv_stashpvn(pTHX_ const char *name, U32 namelen, I32 flags) if (!tmpgv) return NULL; stash = GvHV(tmpgv); + if (!HvNAME_get(stash)) + hv_name_set(stash, name, namelen, 0); assert(stash); - assert(HvNAME_get(stash)); return stash; } diff --git a/t/op/bless.t b/t/op/bless.t index 14ef3d8c1194..7ed3d433cd7f 100644 --- a/t/op/bless.t +++ b/t/op/bless.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan (108); +plan (109); sub expected { my($object, $package, $type) = @_; @@ -139,3 +139,6 @@ expected($c4, 'C4', "SCALAR"); my $a = bless \(keys %h), 'zap'; is(ref $a, 'zap'); } + +bless [], "main::"; +ok(1, 'blessing into main:: does not crash'); # [perl #87388]