git » libjio » commit 2f0dd65

Calls to strdup() alloc memory using malloc(), and there's a leak because we never free() it. This patch fixes this by simply freeing the allocated memory.

author Alberto Bertogli
2004-03-31 01:58:57 UTC
committer Alberto Bertogli
2007-07-15 12:30:17 UTC
parent 5e892fdff3ffde41e16cd5316bca074ae1185fcc

Calls to strdup() alloc memory using malloc(), and there's a leak because we never free() it. This patch fixes this by simply freeing the allocated memory.

Calls to strdup() alloc memory using malloc(), and there's a leak because we
never free() it. This patch fixes this by simply freeing the allocated memory.

Thanks to David Hill for reporting this bug.

libjio.c +6 -0

diff --git a/libjio.c b/libjio.c
index 1601965..a6fa8db 100644
--- a/libjio.c
+++ b/libjio.c
@@ -118,6 +118,9 @@ static int get_jdir(char *filename, char *jdir)
 
 	snprintf(jdir, PATH_MAX, "%s/.%s.jio", dir, base);
 
+	free(baset);
+	free(dirt);
+
 	return 1;
 }
 
@@ -139,6 +142,9 @@ static int get_jtfile(char *filename, int tid, char *jtfile)
 
 	snprintf(jtfile, PATH_MAX, "%s/.%s.jio/%d", dir, base, tid);
 
+	free(baset);
+	free(dirt);
+
 	return 1;
 }