summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-09-19 23:12:48 -0700
committerFather Chrysostomos <sprout@cpan.org>2014-09-20 09:25:02 -0700
commita623f8939cbcaa58a069807591675c0ebcd4135b (patch)
tree6e4f3122df0aefeac3b4eb007f9b869a850c6df9 /scope.c
parentfd01b4b766a3276a9439cade9b1a047c37876c1b (diff)
downloadperl-a623f8939cbcaa58a069807591675c0ebcd4135b.tar.gz
Implement the bipolar read-only system
This fixes bugs related to Hash::Util::unlock accidentally unlocking internal scalars (e.g., that returned by undef()) and allowing them to be modified. Internal read-only values are now marked by two flags, the regular read-only flag, and the new ‘protected’ flag. Before this SvREADONLY served two purposes: 1) The code would use it to protect things that must not be modi- fied, ever (except when the core sees fit to do so). 2) Hash::Util and everybody else would use it to make this unmodifia- ble temporarily when requested by the user. Internals::SvREADONLY serves the latter purpose and only flips the read-only flag, so things that need to stay read-only will remain so, because of the ‘other’ read-only flag, that CPAN doesn’t know about. (If you are a CPAN author, do not read this.)
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index a9c73a4309..cf656c0b0f 100644
--- a/scope.c
+++ b/scope.c
@@ -986,7 +986,7 @@ Perl_leave_scope(pTHX_ I32 base)
/* these flags are the union of all the relevant flags
* in the individual conditions within */
if (UNLIKELY(SvFLAGS(sv) & (
- SVf_READONLY /* for SvREADONLY_off() */
+ SVf_READONLY|SVf_PROTECT /*for SvREADONLY_off*/
| (SVs_GMG|SVs_SMG|SVs_RMG) /* SvMAGICAL() */
| SVf_OOK
| SVf_THINKFIRST)))