Change 16386 by rgs@rgs-home on 2002/05/04 13:22:41
Subject: Re: [PATCH scope.c] Re: local($tied->{foo}) leaks
From: Dave Mitchell <[EMAIL PROTECTED]>
Date: Fri, 3 May 2002 23:51:10 +0100
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/pp_hot.c#277 edit
.... //depot/perl/scope.c#96 edit
Differences ...
==== //depot/perl/pp_hot.c#277 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c.~1~ Sat May 4 07:30:05 2002
+++ perl/pp_hot.c Sat May 4 07:30:05 2002
@@ -1682,8 +1682,17 @@
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 @@
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);
}
==== //depot/perl/scope.c#96 (text) ====
Index: perl/scope.c
--- perl/scope.c.~1~ Sat May 4 07:30:05 2002
+++ perl/scope.c Sat May 4 07:30:05 2002
@@ -206,12 +206,6 @@
PL_localizing = 1;
SvSETMAGIC(sv);
PL_localizing = 0;
- /* If we're localizing a tied array/hash element, this new sv
- * won't actually be stored in the array/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);
}
return sv;
}
End of Patch.