Avoid using cx->blk_loop.itermax when reverse iterating an array.
Nicholas Clark [Thu, 24 Jan 2008 12:15:43 +0000 (12:15 +0000)]
p4raw-id: //depot/perl@33060

pp_ctl.c
pp_hot.c

index c857916..c0f0724 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1918,7 +1918,7 @@ PP(pp_enteriter)
            }
        }
        else if (PL_op->op_private & OPpITER_REVERSED) {
-           cx->blk_loop.itermax = 0;
+           cx->blk_loop.itermax = 0xDEADBEEF;
            cx->blk_loop.iterix = AvFILL(cx->blk_loop.iterary) + 1;
 
        }
index 14a3e08..a7657f8 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1976,7 +1976,8 @@ PP(pp_iter)
     /* iterate array */
     if (PL_op->op_private & OPpITER_REVERSED) {
        /* In reverse, use itermax as the min :-)  */
-       if (cx->blk_loop.iterix <= cx->blk_loop.itermax)
+       if (cx->blk_loop.iterix <= (CxTYPE(cx) == CXt_LOOP_STACK
+                                   ? cx->blk_loop.itermax : 0))
            RETPUSHNO;
 
        if (SvMAGICAL(av) || AvREIFY(av)) {