builtin-grep: terminate correctly at EOF
authorJunio C Hamano <junkio@cox.net>
Thu, 4 May 2006 04:03:25 +0000 (21:03 -0700)
committerJunio C Hamano <junkio@cox.net>
Thu, 4 May 2006 04:03:25 +0000 (21:03 -0700)
It barfed and segfaulted with an incomplete line.

Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-grep.c

index 2124fa6..e87b5cb 100644 (file)
@@ -264,6 +264,8 @@ static int grep_buffer(struct grep_opt *opt, const char *name,
                }
                *eol = ch;
                bol = eol + 1;
+               if (!left)
+                       break;
                left--;
                lno++;
        }