summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2011-03-18 15:37:20 -0700
committerJan Dubois <jand@activestate.com>2011-03-20 00:46:58 -0700
commit658a9f31e43dcb2b52fd873b87444968c94594fa (patch)
treeef56b0f86d8ba09c7e7fb228c43a60cc578ce51b /mg.c
parent8d5d17fad2e8a7a4ca7bd0e424933fd94274f607 (diff)
downloadperl-658a9f31e43dcb2b52fd873b87444968c94594fa.tar.gz
#84774: local $_ calls STORE when $_ is aliased to a tied hash element
local($_) will now strip all magic from $_, so that it is always safe to localize $_, regardless what kind of special (or tied) variable it may have been aliased to.
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mg.c b/mg.c
index 331e34b53d..1ac7e31aba 100644
--- a/mg.c
+++ b/mg.c
@@ -286,7 +286,7 @@ Perl_mg_set(pTHX_ SV *sv)
mg->mg_flags &= ~MGf_GSKIP; /* setting requires another read */
(SSPTR(mgs_ix, MGS*))->mgs_magical = 0;
}
- if (PL_localizing == 2 && !S_is_container_magic(mg))
+ if (PL_localizing == 2 && (!S_is_container_magic(mg) || sv == DEFSV))
continue;
if (vtbl && vtbl->svt_set)
vtbl->svt_set(aTHX_ sv, mg);
@@ -511,6 +511,9 @@ Perl_mg_localize(pTHX_ SV *sv, SV *nsv, bool setmagic)
PERL_ARGS_ASSERT_MG_LOCALIZE;
+ if (nsv == DEFSV)
+ return;
+
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
const MGVTBL* const vtbl = mg->mg_virtual;
if (!S_is_container_magic(mg))