From: Nicholas Clark Date: Sat, 1 Apr 2006 23:34:10 +0000 (+0000) Subject: If the passed in target rv for Perl_newSVrv() was already a reference X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc5494d2ca929464ae4e4345bfcf79797bc9baa8;p=p5sagit%2Fp5-mst-13.2.git If the passed in target rv for Perl_newSVrv() was already a reference to something, it would leak the reference count on that thing. p4raw-id: //depot/perl@27668 --- diff --git a/sv.c b/sv.c index 3eb5c32..c1dcf76 100644 --- a/sv.c +++ b/sv.c @@ -7688,9 +7688,11 @@ Perl_newSVrv(pTHX_ SV *rv, const char *classname) sv_clear(rv); SvFLAGS(rv) = 0; SvREFCNT(rv) = refcnt; - } - if (SvTYPE(rv) < SVt_RV) + sv_upgrade(rv, SVt_RV); + } else if (SvROK(rv)) { + SvREFCNT_dec(SvRV(rv)); + } else if (SvTYPE(rv) < SVt_RV) sv_upgrade(rv, SVt_RV); else if (SvTYPE(rv) > SVt_RV) { SvPV_free(rv);