This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Memory leak cloning PVGVs
authorJirka Hruška <jirka@fud.cz>
Wed, 1 Sep 2010 09:59:35 +0000 (10:59 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 1 Sep 2010 11:24:44 +0000 (12:24 +0100)
[perl #77352]

In S_sv_dup_common, Perl_rvpv_dup was called twice on a non-GP PVGV value,
causing the first duped value to be leaked

AUTHORS
sv.c

diff --git a/AUTHORS b/AUTHORS
index e7e3fb2..20f57a6 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -493,6 +493,7 @@ Jim Meyering                        <meyering@asic.sc.ti.com>
 Jim Miner                      <jfm@winternet.com>
 Jim Richardson
 Jim Schneider                  <jschneid@netilla.com>
+Jirka Hruška                  <jirka@fud.cz>
 Joachim Huober
 Jochen Wiedmann                        <joe@ispsoft.de>
 Jody Belka                     <dev-perl@pimb.org>
diff --git a/sv.c b/sv.c
index 9b0180f..5c46460 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11412,6 +11412,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
                else
                    LvTARG(dstr) = sv_dup_inc(LvTARG(dstr), param);
            case SVt_PVGV:
+               /* non-GP case already handled above */
                if(isGV_with_GP(sstr)) {
                    GvNAME_HEK(dstr) = hek_dup(GvNAME_HEK(dstr), param);
                    /* Don't call sv_add_backref here as it's going to be
@@ -11425,8 +11426,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
                        Perl_sv_add_backref(aTHX_ MUTABLE_SV(GvSTASH(dstr)), dstr);
                    GvGP(dstr)  = gp_dup(GvGP(sstr), param);
                    (void)GpREFCNT_inc(GvGP(dstr));
-               } else
-                   Perl_rvpv_dup(aTHX_ dstr, sstr, param);
+               }
                break;
            case SVt_PVIO:
                /* PL_parser->rsfp_filters entries have fake IoDIRP() */