summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-11-05 14:38:21 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-11-05 14:42:54 -0700
commit9c3f0156b51bc2984d1bae9a562cf5a8f98b6aab (patch)
treee68944b39eade89bca5b2fef2587bd9e5110e652 /scope.c
parentab97dcc3bf50e847e83b6a2d0f3b3f7cd43f1cf6 (diff)
downloadperl-9c3f0156b51bc2984d1bae9a562cf5a8f98b6aab.tar.gz
Hide pad vars from magic methods on scope exit
If, during scope exit, a pad var is being cleared for reuse, it needs to be hidden from magic methods that might reference it through weak references. Otherwise they can end up modifying the var that will be seen next time that scope is entered, by blessing it, etc.
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index d4615d130c..f14be1e4bf 100644
--- a/scope.c
+++ b/scope.c
@@ -901,7 +901,10 @@ Perl_leave_scope(pTHX_ I32 base)
if (SvTHINKFIRST(sv))
sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
+ if (SvTYPE(sv) == SVt_PVHV)
+ Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv));
if (SvMAGICAL(sv))
+ sv_unmagic(sv, PERL_MAGIC_backref),
mg_free(sv);
switch (SvTYPE(sv)) {
@@ -911,7 +914,6 @@ Perl_leave_scope(pTHX_ I32 base)
av_clear(MUTABLE_AV(sv));
break;
case SVt_PVHV:
- Perl_hv_kill_backrefs(aTHX_ MUTABLE_HV(sv));
hv_clear(MUTABLE_HV(sv));
break;
case SVt_PVCV: