This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #117941] Blessing into freed current stash
[perl5.git] / pp.c
diff --git a/pp.c b/pp.c
index 0367023..e63c342 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -607,8 +607,12 @@ PP(pp_bless)
     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;