summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c2
-rw-r--r--mg.c1
-rwxr-xr-xt/op/pat.t26
3 files changed, 28 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 836fdb23d2..6dc45e7450 100644
--- a/gv.c
+++ b/gv.c
@@ -819,6 +819,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
else {
AV* av = GvAVn(gv);
sv_magic((SV*)av, Nullsv, 'D', Nullch, 0);
+ SvREADONLY_on(av);
}
goto magicalize;
case '#':
@@ -869,6 +870,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
else {
AV* av = GvAVn(gv);
sv_magic((SV*)av, (SV*)av, 'D', Nullch, 0);
+ SvREADONLY_on(av);
}
/* FALL THROUGH */
case '1':
diff --git a/mg.c b/mg.c
index 1e5c99480b..06140994cf 100644
--- a/mg.c
+++ b/mg.c
@@ -373,6 +373,7 @@ Perl_magic_regdatum_get(pTHX_ SV *sv, MAGIC *mg)
i = t;
else /* @- */
i = s;
+ SvREADONLY_on(sv);
sv_setiv(sv,i);
}
}
diff --git a/t/op/pat.t b/t/op/pat.t
index fbc234b74d..91c4b7d58f 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -4,7 +4,7 @@
# the format supported by op/regexp.t. If you want to add a test
# that does fit that format, add it to op/re_tests, not here.
-print "1..216\n";
+print "1..220\n";
BEGIN {
chdir 't' if -d 't';
@@ -693,6 +693,30 @@ print "not "
print "ok $test\n";
$test++;
+eval { $+[0] = 13; };
+print "not "
+ if $@ !~ /^Modification of a read-only value attempted/;
+print "ok $test\n";
+$test++;
+
+eval { $-[0] = 13; };
+print "not "
+ if $@ !~ /^Modification of a read-only value attempted/;
+print "ok $test\n";
+$test++;
+
+eval { @+ = (7, 6, 5); };
+print "not "
+ if $@ !~ /^Modification of a read-only value attempted/;
+print "ok $test\n";
+$test++;
+
+eval { @- = qw(foo bar); };
+print "not "
+ if $@ !~ /^Modification of a read-only value attempted/;
+print "ok $test\n";
+$test++;
+
/.(a)(ba*)?/;
print "#$#-..$#+\nnot " if $#+ != 2 or $#- != 1;
print "ok $test\n";