threads / patch / 22451

patch, 3 partsgrep: Fix two memory leaks

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

## tl;dr

2 messages between Jan 30, 2010 and Jan 30, 2010. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Dan McGee· Jan 30, 2010, 15:42 UTC · lore

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(-)
Show changes to builtin-grep.c +2 −0
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
Dan McGee· Jan 30, 2010, 15:45 UTC · re: Dan McGee · lore

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

On Sat, Jan 30, 2010 at 9:42 AM, Dan McGee <dpmcgee@gmail.com> wrote:
Show 7 quoted lines
> 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.

Ignore the misleading numbers in the subject, there isn't more to see here...whoops.

-Dan

← back to recent threads