diff options
author | David Mitchell <davem@iabyn.com> | 2010-09-06 16:24:47 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-09-06 16:28:54 +0100 |
commit | 7dcb9b98df566764105b8c15283b393878a1788e (patch) | |
tree | 415bf0e3f04938b7e2470e2511cb6c027d810d74 /pp.c | |
parent | 44428a460de2170e69440fb654a61fe89892ba53 (diff) | |
download | perl-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.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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) |