Fix [RT#63110] -- two small memory leaks were introduced in 5b9c067
authorAlex Vandiver <alexmv@mit.edu>
Sat, 30 May 2009 00:17:36 +0000 (20:17 -0400)
committerDavid Mitchell <davem@iabyn.com>
Wed, 10 Jun 2009 12:22:36 +0000 (13:22 +0100)
(cherry picked from commit cda5537682a2f5132de1e0387c105e67a72efce4)

hv.c
pp_ctl.c

diff --git a/hv.c b/hv.c
index 1776053..2cefbcb 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1444,7 +1444,7 @@ Perl_hv_copy_hints_hv(pTHX_ HV *const ohv)
        while ((entry = hv_iternext_flags(ohv, 0))) {
            SV *const sv = newSVsv(HeVAL(entry));
            sv_magic(sv, NULL, PERL_MAGIC_hintselem,
-                    (char *)newSVhek (HeKEY_hek(entry)), HEf_SVKEY);
+                    (char *)sv_2mortal(newSVhek (HeKEY_hek(entry))), HEf_SVKEY);
            (void)hv_store_flags(hv, HeKEY(entry), HeKLEN(entry),
                                 sv, HeHASH(entry), HeKFLAGS(entry));
        }
index d12051d..48e158c 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3636,8 +3636,11 @@ PP(pp_entereval)
     SAVEDELETE(PL_defstash, safestr, len);
     SAVEHINTS();
     PL_hints = PL_op->op_targ;
-    if (saved_hh)
+    if (saved_hh) {
+       /* SAVEHINTS created a new HV in PL_hintgv, which we need to GC */
+       SvREFCNT_dec(GvHV(PL_hintgv));
        GvHV(PL_hintgv) = saved_hh;
+    }
     SAVECOMPILEWARNINGS();
     PL_compiling.cop_warnings = DUP_WARNINGS(PL_curcop->cop_warnings);
     if (PL_compiling.cop_hints_hash) {