From: Rafael Garcia-Suarez Date: Wed, 7 Apr 2004 07:37:59 +0000 (+0000) Subject: The optree builder was looping when constructing the ops X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3c9a8b9e0e8ab67833a50cc3f37939286b04437;p=p5sagit%2Fp5-mst-13.2.git The optree builder was looping when constructing the ops for a map/grep block containing a while(1). (Bug reported by Pixel.) p4raw-id: //depot/perl@22667 --- diff --git a/op.c b/op.c index b38c892..46cc07b 100644 --- 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; diff --git a/t/op/grep.t b/t/op/grep.t index 4696224..3e5d716 100755 --- a/t/op/grep.t +++ b/t/op/grep.t @@ -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", ''); +}