If the current stash has been freed, bless() with one argument will
cause a crash when the object’s ‘stash’ is accessed. Simply disallow-
ing this is the easiest fix.
(F) The failing code has attempted to get or set a key which is not in
the current set of allowed keys of a restricted hash.
+=item Attempt to bless into a freed package
+
+(F) You wrote C<bless $foo> with one argument after somehow causing
+the current package to be freed. Perl cannot figure out what to
+do, so it throws up in hands in despair.
+
=item Attempt to bless into a reference
(F) The CLASSNAME argument to the bless() operator is expected to be
HV *stash;
if (MAXARG == 1)
+ {
curstash:
stash = CopSTASH(PL_curcop);
+ if (SvTYPE(stash) != SVt_PVHV)
+ Perl_croak(aTHX_ "Attempt to bless into a freed package");
+ }
else {
SV * const ssv = POPs;
STRLEN len;
require './test.pl';
}
-plan (109);
+plan (110);
sub expected {
my($object, $package, $type) = @_;
bless [], "main::";
ok(1, 'blessing into main:: does not crash'); # [perl #87388]
+
+sub _117941 { package _117941; bless [] }
+delete $::{"_117941::"};
+eval { _117941() };
+like $@, qr/^Attempt to bless into a freed package at /,
+ 'bless with one arg when current stash is freed';