threads / patch / 5479

patchFix memory leak in prepend_to_path (git.c).

Subject: [PATCH] Fix memory leak in prepend_to_path (git.c).

## tl;dr

One message between Sep 5, 2006 and Sep 5, 2006. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Christian Couder· Sep 5, 2006, 06:22 UTC · lore

Some memory was allocated for a new path but not freed after the path was used.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to git.c +2 −0
diff --git a/git.c b/git.c
index 1d00111..335f405 100644
--- a/git.c
+++ b/git.c
@@ -36,6 +36,8 @@ static void prepend_to_path(const char *
 	memcpy(path + len + 1, old_path, path_len - len);
 
 	setenv("PATH", path, 1);
+
+	free(path);
 }
 
 static int handle_options(const char*** argv, int* argc)
-- 
1.4.2.g269a-dirty

← back to recent threads