diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-09-19 23:12:48 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-09-20 09:25:02 -0700 |
commit | a623f8939cbcaa58a069807591675c0ebcd4135b (patch) | |
tree | 6e4f3122df0aefeac3b4eb007f9b869a850c6df9 /universal.c | |
parent | fd01b4b766a3276a9439cade9b1a047c37876c1b (diff) | |
download | perl-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 'universal.c')
-rw-r--r-- | universal.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/universal.c b/universal.c index 906f74c554..94169a6a6e 100644 --- a/universal.c +++ b/universal.c @@ -565,12 +565,12 @@ XS(XS_Internals_SvREADONLY) /* This is dangerous stuff. */ #ifdef PERL_OLD_COPY_ON_WRITE if (SvIsCOW(sv)) sv_force_normal(sv); #endif - SvREADONLY_on(sv); + SvFLAGS(sv) |= SVf_READONLY; XSRETURN_YES; } else { /* I hope you really know what you are doing. */ - SvREADONLY_off(sv); + SvFLAGS(sv) &=~ SVf_READONLY; XSRETURN_NO; } } |