summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2005-11-22 16:32:42 +0000
committerDave Mitchell <davem@fdisolutions.com>2005-11-22 16:32:42 +0000
commit6e585ca0b32392d502ae4276faab9761cc9b1188 (patch)
tree4478db7ed5be6ce4a71d47e6edae1acc8836e113 /pp_ctl.c
parentc106e8bbff313f9d3ffd1a9a1b0a6bd6129af87b (diff)
downloadperl-6e585ca0b32392d502ae4276faab9761cc9b1188.tar.gz
[perl #37725] perl segfaults on reversed array reference
The 'for (reverse @a)' optimisation got its index wrong when create LVALUE SVs for undef elements p4raw-id: //depot/perl@26195
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index a1f111738b..45ca9eaf3c 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1802,8 +1802,8 @@ PP(pp_enteriter)
}
}
else if (PL_op->op_private & OPpITER_REVERSED) {
- cx->blk_loop.itermax = -1;
- cx->blk_loop.iterix = AvFILL(cx->blk_loop.iterary);
+ cx->blk_loop.itermax = 0;
+ cx->blk_loop.iterix = AvFILL(cx->blk_loop.iterary) + 1;
}
}
@@ -1811,8 +1811,8 @@ PP(pp_enteriter)
cx->blk_loop.iterary = PL_curstack;
AvFILLp(PL_curstack) = SP - PL_stack_base;
if (PL_op->op_private & OPpITER_REVERSED) {
- cx->blk_loop.itermax = MARK - PL_stack_base;
- cx->blk_loop.iterix = cx->blk_oldsp;
+ cx->blk_loop.itermax = MARK - PL_stack_base + 1;
+ cx->blk_loop.iterix = cx->blk_oldsp + 1;
}
else {
cx->blk_loop.iterix = MARK - PL_stack_base;