open’s handle vivification could crash if the current stash was freed,
so check before passing a freed stash to gv_init.
Perl_croak_no_modify();
if (cUNOP->op_targ) {
SV * const namesv = PAD_SV(cUNOP->op_targ);
+ HV *stash = CopSTASH(PL_curcop);
+ if (SvTYPE(stash) != SVt_PVHV) stash = NULL;
gv = MUTABLE_GV(newSV(0));
- gv_init_sv(gv, CopSTASH(PL_curcop), namesv, 0);
+ gv_init_sv(gv, stash, namesv, 0);
}
else {
const char * const name = CopSTASHPV(PL_curcop);
use warnings;
use Config;
-plan tests => 121;
+plan tests => 122;
my $Perl = which_perl();
ok( eval { $fh->autoflush(1); 1 }, '$fh->autoflush(1) lives' );
ok( $INC{'IO/File.pm'}, "IO::File now loaded" );
}
+
+sub _117941 { package _117941; open my $a, "TEST" }
+delete $::{"_117941::"};
+_117941();
+pass("no crash when open autovivifies glob in freed package");