diff options
author | Jan Dubois <jand@activestate.com> | 2000-08-17 11:31:55 -0700 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-08-18 02:08:42 +0000 |
commit | 0199fce9e831d70af0aeef6c5962dc695c3c246f (patch) | |
tree | 591066d88034d2d4af4e9b86bd851175b8baf6b3 | |
parent | e1ca407b4adcd5a31e0df6bc6b8955a291235650 (diff) | |
download | perl-0199fce9e831d70af0aeef6c5962dc695c3c246f.tar.gz |
newSVrv() memory leak
Message-ID: <l64ppsggaiuc4t6msm45iqohmhpjblb4qf@4ax.com>
p4raw-id: //depot/perl@6687
-rw-r--r-- | sv.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -5534,8 +5534,23 @@ Perl_newSVrv(pTHX_ SV *rv, const char *classname) SV_CHECK_THINKFIRST(rv); SvAMAGIC_off(rv); + if (SvTYPE(rv) >= SVt_PVMG) { + U32 refcnt = SvREFCNT(rv); + SvREFCNT(rv) = 0; + sv_clear(rv); + SvFLAGS(rv) = 0; + SvREFCNT(rv) = refcnt; + } + if (SvTYPE(rv) < SVt_RV) - sv_upgrade(rv, SVt_RV); + sv_upgrade(rv, SVt_RV); + else if (SvTYPE(rv) > SVt_RV) { + (void)SvOOK_off(rv); + if (SvPVX(rv) && SvLEN(rv)) + Safefree(SvPVX(rv)); + SvCUR_set(rv, 0); + SvLEN_set(rv, 0); + } (void)SvOK_off(rv); SvRV(rv) = sv; |