git/list[1] front-page[2] threads[3] people[4] search[5] about
 

segfault bug in internal git grep from next

From
MRMarco Roeland <marco.roeland@xs4all.nl>
Date
May 3, 2006, 08:32 UTC
Message-ID
<20060503083229.GA15579@fiberbit.xs4all.nl>
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
Next: Marco Roeland
Message 1 of 2 in “segfault bug in internal git grep from next”
  1. Marco RoelandMay 3, 2006
  2. Marco RoelandMay 4, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.