summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2002-05-04 00:51:10 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-05-04 13:22:41 +0000
commitb412ba13de1aba05d1c6879f79a05afb87caff24 (patch)
tree79f3486fb74ffe906983042b7f22567caafd2bd9 /pp_hot.c
parent70a63e5f3c7f94ba3250f14cfab6845bafe96a42 (diff)
downloadperl-b412ba13de1aba05d1c6879f79a05afb87caff24.tar.gz
Re: [PATCH scope.c] Re: local($tied->{foo}) leaks
Message-ID: <20020503235110.E22026@fdgroup.com> p4raw-id: //depot/perl@16386
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 027d1249ac..30653a76b7 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1682,8 +1682,17 @@ PP(pp_helem)
STRLEN keylen;
char *key = SvPV(keysv, keylen);
SAVEDELETE(hv, savepvn(key,keylen), keylen);
- } else
+ } else {
+ SV *sv;
save_helem(hv, keysv, svp);
+ sv = *svp;
+ /* If we're localizing a tied hash element, this new
+ * sv won't actually be stored in the hash - so it
+ * won't get reaped when the localize ends. Ensure it
+ * gets reaped by mortifying it instead. DAPM */
+ if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
+ sv_2mortal(sv);
+ }
}
}
else if (PL_op->op_private & OPpDEREF)
@@ -2938,8 +2947,17 @@ PP(pp_aelem)
PUSHs(lv);
RETURN;
}
- if (PL_op->op_private & OPpLVAL_INTRO)
+ if (PL_op->op_private & OPpLVAL_INTRO) {
+ SV *sv;
save_aelem(av, elem, svp);
+ sv = *svp;
+ /* If we're localizing a tied array element, this new sv
+ * won't actually be stored in the array - so it won't get
+ * reaped when the localize ends. Ensure it gets reaped by
+ * mortifying it instead. DAPM */
+ if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
+ sv_2mortal(sv);
+ }
else if (PL_op->op_private & OPpDEREF)
vivify_ref(*svp, PL_op->op_private & OPpDEREF);
}