This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The optree builder was looping when constructing the ops
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 7 Apr 2004 07:37:59 +0000 (07:37 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 7 Apr 2004 07:37:59 +0000 (07:37 +0000)
for a map/grep block containing a while(1).
(Bug reported by Pixel.)

p4raw-id: //depot/perl@22667

op.c
t/op/grep.t

diff --git a/op.c b/op.c
index b38c892..46cc07b 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5430,7 +5430,7 @@ Perl_ck_grep(pTHX_ OP *o)
        OP* k;
        o = ck_sort(o);
         kid = cLISTOPo->op_first->op_sibling;
-       for (k = cLISTOPo->op_first->op_sibling->op_next; k; k = k->op_next) {
+       for (k = cUNOPx(kid)->op_first; k; k = k->op_next) {
            kid = k;
        }
        kid->op_next = (OP*)gwop;
index 4696224..3e5d716 100755 (executable)
@@ -4,7 +4,7 @@
 # grep() and map() tests
 #
 
-print "1..37\n";
+print "1..38\n";
 
 $test = 1;
 
@@ -162,3 +162,8 @@ sub ok {
     undef $gimme; map { gimme } @list;  ok($gimme, 'list');   $test++;
 }
 
+{
+    # This shouldn't loop indefinitively.
+    my @empty = map { while (1) {} } ();
+    ok("@empty", '');
+}