diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-21 08:24:06 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-22 04:54:06 -0800 |
commit | 199670db6c499615e0f5f53e3c84aa6f11584ff1 (patch) | |
tree | 25209d29cddef71a5d6a8865cd738e7cdf5d3c0a /mg.c | |
parent | 1b0fd1e8346658cb037cc394f0c428007124b916 (diff) | |
download | perl-199670db6c499615e0f5f53e3c84aa6f11584ff1.tar.gz |
Protect ${^E_NCODING} from abuse
When read, it is now always undef. When set, it croaks as though
read-only except in the encoding package. Hopefully that will dis-
suade anyone from depending on it.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -858,6 +858,8 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) if (nextchar != '\0') { if (strEQ(remaining, "NCODING")) sv_setsv(sv, _get_encoding()); + else if (strEQ(remaining, "_NCODING")) + sv_setsv(sv, NULL); break; } @@ -2648,6 +2650,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) /* It may be the shadow variable ${E_NCODING} which has lexical * scope. See comments at Perl__get_encoding in this file */ if (*(mg->mg_ptr + 1) == '_') { + if (CopSTASH(PL_curcop) != get_hv("encoding::",0)) + Perl_croak_no_modify(); lex = TRUE; offset++; } |