summaryrefslogtreecommitdiff
path: root/pp_sort.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-06-26 00:18:03 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-06-26 01:12:10 -0700
commit20d5dc239d1bc8440adfec25faf617e0e444f64e (patch)
tree8ebab95b5783396ff210544b5e03d3317dfd7706 /pp_sort.c
parentae3f739188e3ee21fa593cafc28023c533e8d9bf (diff)
downloadperl-20d5dc239d1bc8440adfec25faf617e0e444f64e.tar.gz
In-place sort should not leave array read-only
$ ./perl -Ilib -e '@a=1..2; eval { @a=sort{die} @a }; warn "ok so far\n"; @a = 1' ok so far Modification of a read-only value attempted at -e line 1. If something goes wrong inside the sort block and it dies, we still need to make sure we turn off the read-only flag on that array.
Diffstat (limited to 'pp_sort.c')
-rw-r--r--pp_sort.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pp_sort.c b/pp_sort.c
index 56c0aac5db..a67ad4e335 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1588,7 +1588,10 @@ PP(pp_sort)
if (SvREADONLY(av))
Perl_croak_no_modify();
else
+ {
SvREADONLY_on(av);
+ save_pushptr((void *)av, SAVEt_READONLY_OFF);
+ }
p1 = p2 = AvARRAY(av);
sorting_av = 1;
}