Leaking is bad, m'kay.
Nicholas Clark [Tue, 24 May 2005 15:21:48 +0000 (15:21 +0000)]
p4raw-id: //depot/perl@24566

hv.c
sv.c

diff --git a/hv.c b/hv.c
index 2996a8e..5443771 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1596,6 +1596,7 @@ S_hfreeentries(pTHX_ HV *hv)
            HvLAZYDEL_off(hv);
            hv_free_ent(hv, entry);
        }
+       Safefree(iter->xhv_name);
        Safefree(iter);
        ((XPVHV*) SvANY(hv))->xhv_aux = 0;
     }
@@ -1772,7 +1773,9 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, STRLEN len, int flags)
 {
     struct xpvhv_aux *iter = ((XPVHV *)SvANY(hv))->xhv_aux;
 
-    if (!iter) {
+    if (iter) {
+       Safefree(iter->xhv_name);
+    } else {
        if (name == 0)
            return;
 
diff --git a/sv.c b/sv.c
index 718ecfe..b3e3d94 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10915,15 +10915,13 @@ Perl_sv_dup(pTHX_ SV *sstr, CLONE_PARAMS* param)
            const char *hvname = HvNAME_get((HV*)sstr);
            struct xpvhv_aux *aux = ((XPVHV *)SvANY(sstr))->xhv_aux;
 
+           ((XPVHV *)SvANY(dstr))->xhv_aux = 0;
            if (aux) {
-               New(0, ((XPVHV *)SvANY(dstr))->xhv_aux, 1, struct xpvhv_aux);
                HvRITER_set((HV*)dstr, HvRITER_get((HV*)sstr));
                /* FIXME strlen HvNAME  */
                Perl_hv_name_set(aTHX_ (HV*) dstr, hvname,
                                 hvname ? strlen(hvname) : 0,
                                 0);
-           } else {
-               ((XPVHV *)SvANY(dstr))->xhv_aux = 0;
            }
            if (HvARRAY((HV*)sstr)) {
                STRLEN i = 0;