From 82609a17e5b4183b9ac0efa8d81ad02e7206f357 Mon Sep 17 00:00:00 2001 From: bbrtj Date: Sun, 14 Dec 2025 20:41:28 +0100 Subject: [PATCH 1/2] Fix Perl_av_store off by one error in key comparison --- av.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/av.c b/av.c index 352c1ac03491..3a83fec6ff94 100644 --- a/av.c +++ b/av.c @@ -361,7 +361,7 @@ Perl_av_store(pTHX_ AV *av, SSize_t key, SV *val) return NULL; } - if (SvREADONLY(av) && key >= AvFILL(av)) + if (SvREADONLY(av) && key > AvFILL(av)) croak_no_modify(); if (!AvREAL(av) && AvREIFY(av)) From 32768ce2e49d68b6a9fbc983729390a6e66c4fe9 Mon Sep 17 00:00:00 2001 From: bbrtj Date: Tue, 16 Dec 2025 06:23:22 +0100 Subject: [PATCH 2/2] Add a regression test for GH #24006 --- t/op/array.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/op/array.t b/t/op/array.t index cde0ad1251e6..79186b0c6464 100644 --- a/t/op/array.t +++ b/t/op/array.t @@ -6,7 +6,7 @@ BEGIN { set_up_inc('.', '../lib'); } -plan (198); +plan (199); # # @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them @@ -734,3 +734,15 @@ fresh_perl_is('my @x;$x[0] = 1;shift @x;$x[22] = 1;$x[25] = 1;','', is($arr[1], 3, 'Array element within array range created at correct index from subroutine @_ alias; GH 16364'); } + +# regression test for GH #24006 +{ + use feature qw(refaliasing); + no warnings 'experimental::refaliasing'; + my @arr = (1, 2); + Internals::SvREADONLY(@arr, 1); + + eval { \$arr[1] = \42 }; + ok !$@, "Last element's contents of a readonly array can be modified"; +} +