summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c2
-rwxr-xr-xt/op/grep.t7
2 files changed, 7 insertions, 2 deletions
diff --git a/op.c b/op.c
index b38c892927..46cc07b029 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 4696224c44..3e5d7168a0 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", '');
+}