This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix memory leak introduced by 2d0d1eccfcfe
authorFather Chrysostomos <sprout@cpan.org>
Tue, 16 Nov 2010 01:00:52 +0000 (17:00 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 16 Nov 2010 01:00:52 +0000 (17:00 -0800)
If HvENAME was set by a destructor, it needs to be freed as well.
hv_name_set(whatever, NULL, ...) does that.

hv.c

diff --git a/hv.c b/hv.c
index c3db1c6..aa06c62 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1855,8 +1855,8 @@ Perl_hv_undef(pTHX_ HV *hv)
     if (SvOOK(hv)) {
       struct xpvhv_aux * const aux = HvAUX(hv);
       struct mro_meta *meta;
-      if ((name = HvNAME(hv))) {
-        if (PL_stashcache)
+      if (aux->xhv_name) {
+        if (PL_stashcache && (name = HvNAME(hv)))
            (void)hv_delete(PL_stashcache, name, HvNAMELEN_get(hv), G_DISCARD);
        hv_name_set(hv, NULL, 0, 0);
       }