Integrate #10145 from maintperl.
Jarkko Hietaniemi [Thu, 17 May 2001 20:06:23 +0000 (20:06 +0000)]
fix for ID 20010515.004 (needs test)

p4raw-id: //depot/perl@10148
p4raw-integrated: from //depot/maint-5.6/perl@10147 'merge in' pp_hot.c
(@10091..)

pp_hot.c

index 023a05b..9e484fc 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1812,9 +1812,17 @@ PP(pp_iter)
 
     SvREFCNT_dec(*itersvp);
 
-    if ((sv = SvMAGICAL(av)
-             ? *av_fetch(av, ++cx->blk_loop.iterix, FALSE)
-             : AvARRAY(av)[++cx->blk_loop.iterix]))
+    if (SvMAGICAL(av) || AvREIFY(av)) {
+       SV **svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
+       if (svp)
+           sv = *svp;
+       else
+           sv = Nullsv;
+    }
+    else {
+       sv = AvARRAY(av)[++cx->blk_loop.iterix];
+    }
+    if (sv)
        SvTEMP_off(sv);
     else
        sv = &PL_sv_undef;