From 57c404c9ca0d045fece7cbd7010d0d084cef5821 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 20 Sep 2014 06:41:29 -0700 Subject: [PATCH] [perl #115254] Fix flag check on scope exit $ ./perl -Ilib -e '{ my $x = 3; Internals::SvREADONLY $x, 1; () }' $ ./perl -Ilib -e '{ my $x = ${qr//}; Internals::SvREADONLY $x, 1; () }' Modification of a read-only value attempted at -e line 1. The latter causes $x to be marked FAKE. At the time this code was introduced in scope.c, read-only+fake meant cow, so the !fake check was necessary. (That said, it has always behaved incorrectly for glob copies that are also marked fake.) --- scope.c | 2 +- t/lib/universal.t | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scope.c b/scope.c index cf656c0..5eb9ddb 100644 --- a/scope.c +++ b/scope.c @@ -996,7 +996,7 @@ Perl_leave_scope(pTHX_ I32 base) * readonlyness so that it can go out of scope * quietly */ - if (SvREADONLY(sv) && !SvFAKE(sv)) + if (SvREADONLY(sv)) SvREADONLY_off(sv); if (SvOOK(sv)) { /* OOK or HvAUX */ diff --git a/t/lib/universal.t b/t/lib/universal.t index 55fda06..d3510c4 100644 --- a/t/lib/universal.t +++ b/t/lib/universal.t @@ -6,7 +6,7 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl'; - plan( tests => 15 ); + plan( tests => 16 ); } for my $arg ('', 'q[]', qw( 1 undef )) { @@ -66,3 +66,6 @@ eval { ${\!0} = 7 }; like $@, qr "^Modification of a read-only value", 'protected values still croak on assignment after SvREADONLY(..., 0)'; is ${\3} == 3, "1", 'attempt to modify failed'; + +eval { { my $x = ${qr//}; Internals::SvREADONLY $x, 1; () } }; +is $@, "", 'read-only lexical regexps on scope exit [perl #115254]'; -- 1.8.3.1