This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop renamed packages from making reset() crash
[perl5.git] / perl.c
diff --git a/perl.c b/perl.c
index fe71325..a6f9c14 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -845,7 +845,6 @@ perl_destruct(pTHXx)
            ary[i] = &PL_sv_undef;
        }
     }
-    Safefree(PL_stashpad);
 #endif
 
 
@@ -1079,6 +1078,10 @@ perl_destruct(pTHXx)
     while (sv_clean_all() > 2)
        ;
 
+#ifdef USE_ITHREADS
+    Safefree(PL_stashpad); /* must come after sv_clean_all */
+#endif
+
     AvREAL_off(PL_fdpid);              /* no surviving entries */
     SvREFCNT_dec(PL_fdpid);            /* needed in io_close() */
     PL_fdpid = NULL;