This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
{Dos,}Glob.xs: Skip freeing during global destruction
authorFather Chrysostomos <sprout@cpan.org>
Thu, 13 Dec 2012 02:09:57 +0000 (18:09 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 13 Dec 2012 02:09:57 +0000 (18:09 -0800)
See ticket #116064.

File::Glob and ::DosGlob free data associated with a calling op when
that op is freed.

During global destruction, there is no need to do that, as it will be
freed anyway.

Also, during sv_clean_all dMY_CXT can cause us to read freed memory.

ext/File-DosGlob/DosGlob.xs
ext/File-Glob/Glob.xs

index 929a237..cbd9178 100644 (file)
@@ -16,12 +16,15 @@ START_MY_CXT
 static void
 glob_ophook(pTHX_ OP *o)
 {
+  if (PL_dirty) return;
+  {
     dMY_CXT;
     if (!MY_CXT.x_DG_ENTRIES)
        MY_CXT.x_DG_ENTRIES = get_hv("File::DosGlob::entries", 0);
     if (MY_CXT.x_DG_ENTRIES)
        hv_delete(MY_CXT.x_DG_ENTRIES, (char *)&o, sizeof(OP *),G_DISCARD);
     if (MY_CXT.x_DG_OLD_OPHOOK) MY_CXT.x_DG_OLD_OPHOOK(aTHX_ o);
+  }
 }
 
 MODULE = File::DosGlob         PACKAGE = File::DosGlob
index ea8930c..df5530a 100644 (file)
@@ -316,12 +316,15 @@ doglob_iter_wrapper(pTHX_ AV *entries, SV *patsv)
 static void
 glob_ophook(pTHX_ OP *o)
 {
+  if (PL_dirty) return;
+  {
     dMY_CXT;
     if (MY_CXT.x_GLOB_ENTRIES
      && (o->op_type == OP_GLOB || o->op_type == OP_ENTERSUB))
        hv_delete(MY_CXT.x_GLOB_ENTRIES, (char *)&o, sizeof(OP *),
                  G_DISCARD);
     if (MY_CXT.x_GLOB_OLD_OPHOOK) MY_CXT.x_GLOB_OLD_OPHOOK(aTHX_ o);
+  }
 }
 
 MODULE = File::Glob            PACKAGE = File::Glob