Skip to contentSkip to conversation

grep: Fix two memory leaks

PATCH In review Dan McGee 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore

Dan McGee

author
#0 lore raw

PATCH 2/3 grep: Fix two memory leaks

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.

---
Found these with valgrind.

-Dan

 builtin-grep.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
builtin-grep.c +2 -0
index 9bd467c..0ef849c 100644
@@ -205,6 +205,8 @@ static void *run(void *arg)
 
 		work_done(w);
 	}
+	free_grep_patterns(arg);
+	free(arg);
 
 	return (void*) (intptr_t) hit;
 }
Signature · 1 line
1.6.6.1
author
#1 lore raw
Quoted 7 lines · Dan McGee

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.

---
Found these with valgrind.

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

-Dan