summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2002-05-08 01:11:02 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2002-05-07 22:24:59 +0000
commitbfc4de9ff33050d7c71e12b604bc53895468baad (patch)
tree6c3e5220924d3e7de4228a28d745ca21503f2c79 /scope.c
parent8d1f198fe997a3eac9dc901e973cdc46ac8bbdec (diff)
downloadperl-bfc4de9ff33050d7c71e12b604bc53895468baad.tar.gz
Re: [PATCH scope.c] Re: local($tied->{foo}) leaks
Message-ID: <20020508001102.D4118@fdgroup.com> p4raw-id: //depot/perl@16456
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/scope.c b/scope.c
index 85a068017c..a1fdfd120e 100644
--- a/scope.c
+++ b/scope.c
@@ -587,23 +587,39 @@ Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
void
Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
{
+ SV *sv;
SSCHECK(4);
SSPUSHPTR(SvREFCNT_inc(av));
SSPUSHINT(idx);
SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_AELEM);
save_scalar_at(sptr);
+ sv = *sptr;
+ /* 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);
}
void
Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
{
+ SV *sv;
SSCHECK(4);
SSPUSHPTR(SvREFCNT_inc(hv));
SSPUSHPTR(SvREFCNT_inc(key));
SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_HELEM);
save_scalar_at(sptr);
+ sv = *sptr;
+ /* 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);
}
void