threads / bug / 4033

segfault bug in internal git grep from next

Subject: segfault bug in internal git grep from next

## tl;dr

2 messages between May 3, 2006 and May 4, 2006.

replies: 1people: 1as markdown or json

Marco Roeland· May 3, 2006, 08:32 UTC · lore
Hello!
I'm using the next branch as of commit 6a40327d242dac9f85c6d63c94d537b45ba86e89

A segfault occurs in using the new builtin grep when using it on a binary file, so no regular \n endings.

A testcase is the attached (if it survives the vger filters) "git.png" icon as it is used for example on the http://www.kernel.org/git website.

I tried the obvious, this is the line that gives the segfault:
diff --git a/builtin-grep.c b/builtin-grep.c
index 09e3677..5d4f319 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -121,7 +121,7 @@ static void compile_patterns(struct grep
 static char *end_of_line(char *cp, unsigned long *left)
 {
 	unsigned long l = *left;
-	while (l && *cp != '\n') {
+	while (l && *cp && *cp != '\n') {
 		l--;
 		cp++;
 	}

but it did not solve the problem. Unfortunately I have no time at the
moment to investigate further, so just this report at the moment.

On a side-note it might be handy to add the icon to the main git
repository and to use it in (new) test cases for git grep. Of course
grepping in binary files is mostly not very useful, but lots of
real-world repo's have some binaries.
-- 
Marco Roeland
Marco Roeland· May 4, 2006, 08:44 UTC · re: Marco Roeland · lore

Re: segfault bug in internal git grep from next (fixed)

On Wednesday May 3rd 2006 Marco Roeland wrote:
> I'm using the next branch as of commit 6a40327d242dac9f85c6d63c94d537b45ba86e89
> 
> A segfault occurs in using the new builtin grep when using it on a
> binary file, so no regular \n endings.
Fixed by Junio in commit 7ed36f56e33bd838d06521a37a916516397e9e8b.

I really use git grep a lot. It is very powerful, and the builtin version makes even more possible. Thanks very much,

-- 
Marco Roeland

← back to recent threads