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

2 messages from 2010-01-30 to 2010-01-30. Participants: Dan McGee.
Thread: https://gitlist.dev/t/22451

## Dan McGee, 2010-01-30 15:42

Subject: [PATCH 2/3] grep: Fix two memory leaks
Message-ID: <1264866178-12048-1-git-send-email-dpmcgee@gmail.com>
URL: https://gitlist.dev/e/1264866178-12048-1-git-send-email-dpmcgee%40gmail.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

```

## Dan McGee, 2010-01-30 15:45

Subject: Re: [PATCH 2/3] grep: Fix two memory leaks
Message-ID: <449c10961001300745m495986acw5f1cfe5c22f4ee1f@mail.gmail.com>
URL: https://gitlist.dev/e/449c10961001300745m495986acw5f1cfe5c22f4ee1f%40mail.gmail.com
In-Reply-To: <1264866178-12048-1-git-send-email-dpmcgee@gmail.com>

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

```
