This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Unshare the shared string gp_file_hek only if it exists in a GP.
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 22 Dec 2006 11:30:47 +0000 (11:30 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 22 Dec 2006 11:30:47 +0000 (11:30 +0000)
Not doing this will produce invalid frees in the global destruction
process, probably because the empty string will get freed several
times. This should be safe since gp_file_hek is only assigned a
new value with share_hek().

p4raw-id: //depot/perl@29610

gv.c

diff --git a/gv.c b/gv.c
index 394e684..4878d80 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -1442,7 +1442,8 @@ Perl_gp_free(pTHX_ GV *gv)
         return;
     }
 
-    unshare_hek(gp->gp_file_hek);
+    if (gp->gp_file_hek)
+       unshare_hek(gp->gp_file_hek);
     SvREFCNT_dec(gp->gp_sv);
     SvREFCNT_dec(gp->gp_av);
     /* FIXME - another reference loop GV -> symtab -> GV ?