summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-09-06 16:24:47 +0100
committerDavid Mitchell <davem@iabyn.com>2010-09-06 16:28:54 +0100
commit7dcb9b98df566764105b8c15283b393878a1788e (patch)
tree415bf0e3f04938b7e2470e2511cb6c027d810d74 /pp.c
parent44428a460de2170e69440fb654a61fe89892ba53 (diff)
downloadperl-7dcb9b98df566764105b8c15283b393878a1788e.tar.gz
$ref++, $ref-- leaked referent
[perl #9466] pp_postinc and pp_postdec used a pad TARG to return a copy of the original value. When that value was a reference, it meant a copy of the reference would hang out in the pad forever and so the referent would leak. Fix this by using a mortal instead.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index 31614ed0e6..78ed2867ab 100644
--- a/pp.c
+++ b/pp.c
@@ -899,6 +899,8 @@ PP(pp_postinc)
dVAR; dSP; dTARGET;
if (SvTYPE(TOPs) >= SVt_PVAV || isGV_with_GP(TOPs))
Perl_croak_no_modify(aTHX);
+ if (SvROK(TOPs))
+ TARG = sv_newmortal();
sv_setsv(TARG, TOPs);
if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
&& SvIVX(TOPs) != IV_MAX)
@@ -921,6 +923,8 @@ PP(pp_postdec)
dVAR; dSP; dTARGET;
if (SvTYPE(TOPs) >= SVt_PVAV || isGV_with_GP(TOPs))
Perl_croak_no_modify(aTHX);
+ if (SvROK(TOPs))
+ TARG = sv_newmortal();
sv_setsv(TARG, TOPs);
if (!SvREADONLY(TOPs) && SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)
&& SvIVX(TOPs) != IV_MIN)