This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
gv.c: gp_free UTF8 cleanup
authorBrian Fraser <fraserbn@gmail.com>
Wed, 6 Jul 2011 05:36:37 +0000 (02:36 -0300)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 6 Oct 2011 20:01:05 +0000 (13:01 -0700)
gv.c

diff --git a/gv.c b/gv.c
index 1963e08..a63b976 100644 (file)
--- a/gv.c
+++ b/gv.c
@@ -2112,10 +2112,11 @@ Perl_gp_free(pTHX_ GV *gv)
       /* FIXME - another reference loop GV -> symtab -> GV ?
          Somehow gp->gp_hv can end up pointing at freed garbage.  */
       if (hv && SvTYPE(hv) == SVt_PVHV) {
       /* FIXME - another reference loop GV -> symtab -> GV ?
          Somehow gp->gp_hv can end up pointing at freed garbage.  */
       if (hv && SvTYPE(hv) == SVt_PVHV) {
-       const char *hvname = HvNAME_get(hv);
-       if (PL_stashcache && hvname)
-           (void)hv_delete(PL_stashcache, hvname, HvNAMELEN_get(hv),
-                     G_DISCARD);
+        const HEK *hvname_hek = HvNAME_HEK(hv);
+        if (PL_stashcache && hvname_hek)
+           (void)hv_delete(PL_stashcache, HEK_KEY(hvname_hek),
+                      (HEK_UTF8(hvname_hek) ? -HEK_LEN(hvname_hek) : HEK_LEN(hvname_hek)),
+                      G_DISCARD);
        SvREFCNT_dec(hv);
       }
       SvREFCNT_dec(io);
        SvREFCNT_dec(hv);
       }
       SvREFCNT_dec(io);