summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-11-03 20:12:29 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-11-03 20:16:53 -0800
commit8c995aba0072b817ab8b2419eefed8447f6ea3aa (patch)
treeec4a0aa153535bca72d850c730fc56c9592f8938 /gv.c
parent1d5686ec7b423f88ee27ac6dfd9a6de27e442e2e (diff)
downloadperl-8c995aba0072b817ab8b2419eefed8447f6ea3aa.tar.gz
[perl #123103] Just set SVf_READONLY on magic vars
a623f8939 was arguably a little too eager. It’s purpose is to protect vars whose modification can causes hangs and crashes. I don’t believe that is the case for any magic vars.
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gv.c b/gv.c
index c8d434544c..eaf9d21501 100644
--- a/gv.c
+++ b/gv.c
@@ -1767,6 +1767,12 @@ S_find_default_stash(pTHX_ HV **stash, const char *name, STRLEN len,
return TRUE;
}
+/* gv_magicalize only turns on the SVf_READONLY flag, not SVf_PROTECT. So
+ redefine SvREADONLY_on for that purpose. We don’t use it later on in
+ this file. */
+#undef SvREADONLY_on
+#define SvREADONLY_on(sv) (SvFLAGS(sv) |= SVf_READONLY)
+
/* gv_magicalize() is called by gv_fetchpvn_flags when creating
* a new GV.
* Note that it does not insert the GV into the stash prior to
@@ -2148,6 +2154,10 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len,
return addmg;
}
+/* If we do ever start using this later on in the file, we need to make
+ sure we don’t accidentally use the wrong definition. */
+#undef SvREADONLY_on
+
/* This function is called when the stash already holds the GV of the magic
* variable we're looking for, but we need to check that it has the correct
* kind of magic. For example, if someone first uses $! and then %!, the