[perl #117941] reset crashes when current stash is freed
authorFather Chrysostomos <sprout@cpan.org>
Sat, 8 Jun 2013 07:23:02 +0000 (00:23 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 8 Jun 2013 07:23:02 +0000 (00:23 -0700)
sv.c
t/op/reset.t

diff --git a/sv.c b/sv.c
index bcc9a22..c45d4b1 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -8982,7 +8982,7 @@ Perl_sv_resetpvn(pTHX_ const char *s, STRLEN len, HV * const stash)
     char todo[PERL_UCHAR_MAX+1];
     const char *send;
 
-    if (!stash)
+    if (!stash || SvTYPE(stash) != SVt_PVHV)
        return;
 
     if (!s) {          /* reset ?? searches */
index 291bc39..5c3b162 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
 }
 use strict;
 
-plan tests => 30;
+plan tests => 31;
 
 package aiieee;
 
@@ -120,6 +120,10 @@ fresh_perl_is( # it crashes more reliably with a smaller script
   "ok\n", {},
   "no crash if package is effectively renamed before op is freed");
 
+sub _117941 { package _117941; reset }
+delete $::{"_117941::"};
+_117941();
+pass("no crash when current package is freed");
 
 undef $/;
 my $prog = <DATA>;