summaryrefslogtreecommitdiff
path: root/ext/arybase
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-02-01 13:29:28 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-02-01 13:44:29 -0800
commit60aa0b5df451ec35a916c5ff586c7890e804c5ff (patch)
tree450e828ebc1c2f058234e169b468f973e2968e89 /ext/arybase
parent402642c6301a1dbc64ea3acc8beee35078afee26 (diff)
downloadperl-60aa0b5df451ec35a916c5ff586c7890e804c5ff.tar.gz
[perl #109570] Fix off-by-1 error in arybase’s lslice
When I wrote that originally, I was treating POPMARK as equivalent to --*PL_markstack_ptr, rather than *PL_markstack_ptr--. So I was using the marker for the outer list surrounding the list slice, and modifying whatever numbers were to be found there, such as the 3 and 4 in [3, 4, qw(foo bar)[0]].
Diffstat (limited to 'ext/arybase')
-rw-r--r--ext/arybase/arybase.xs4
-rw-r--r--ext/arybase/t/lslice.t3
2 files changed, 4 insertions, 3 deletions
diff --git a/ext/arybase/arybase.xs b/ext/arybase/arybase.xs
index 296733a7cc..68b9cf99cc 100644
--- a/ext/arybase/arybase.xs
+++ b/ext/arybase/arybase.xs
@@ -245,8 +245,8 @@ static OP *ab_pp_basearg(pTHX) {
count = SP-firstp;
break;
case OP_LSLICE:
- firstp = PL_stack_base + *(PL_markstack_ptr-2)+1;
- count = TOPMARK - *(PL_markstack_ptr-2);
+ firstp = PL_stack_base + *(PL_markstack_ptr-1)+1;
+ count = TOPMARK - *(PL_markstack_ptr-1);
if (GIMME != G_ARRAY) {
firstp += count-1;
count = 1;
diff --git a/ext/arybase/t/lslice.t b/ext/arybase/t/lslice.t
index c012b84f5e..0db7a078f2 100644
--- a/ext/arybase/t/lslice.t
+++ b/ext/arybase/t/lslice.t
@@ -1,7 +1,7 @@
use warnings; no warnings 'deprecated';
use strict;
-use Test::More tests => 11;
+use Test::More tests => 12;
our @i4 = (3, 5, 3, 5);
@@ -11,6 +11,7 @@ is_deeply [ scalar qw(a b c d e f)[3,4] ], [ qw(b) ];
is_deeply [ qw(a b c d e f)[3,4,8,9] ], [ qw(a b f), undef ];
is_deeply [ scalar qw(a b c d e f)[@i4] ], [ qw(c) ];
is_deeply [ qw(a b c d e f)[@i4] ], [ qw(a c a c) ];
+is_deeply [ 3, 4, qw(a b c d e f)[@i4] ], [ 3, 4, qw(a c a c) ];
is_deeply [ qw(a b c d e f)[-1,-2] ], [ qw(f e) ];
is_deeply [ qw(a b c d e f)[2,1] ], [ qw(f e) ];