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

[PATCH 2/3] grep: Fix two memory leaks

From
Dan McGee <dpmcgee@gmail.com>
Date
Jan 30, 2010, 15:42 UTC
Message-ID
<1264866178-12048-1-git-send-email-dpmcgee@gmail.com>

We duplicate the grep_opt structure when using grep threads, but didn't later free either the patterns attached to this new structure or the structure itself.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
---
Found these with valgrind.
-Dan
 builtin-grep.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-grep.c b/builtin-grep.c
index 9bd467c..0ef849c 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -205,6 +205,8 @@ static void *run(void *arg)
 
 		work_done(w);
 	}
+	free_grep_patterns(arg);
+	free(arg);
 
 	return (void*) (intptr_t) hit;
 }
-- 
1.6.6.1
Next: Dan McGee
Message 1 of 2 in “grep: Fix two memory leaks”
  1. 2/3 grep: Fix two memory leaksDan McGee, Jan 30, 2010
  2. Dan McGeeJan 30, 2010

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.