[PATCH] Fixed a small memory leak in divelist.c

Lubomir I. Ivanov neolit123 at gmail.com
Wed Aug 1 12:19:44 PDT 2012


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

In fill_one_dive(), cylinder and location strings are obtained via
get_string(), which needs to allocated a litte bit of memory.

After passing the two pointers ('cylinder' and 'location') as arguments
to gtk_list_store_set() it is safe to release them.

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 divelist.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/divelist.c b/divelist.c
index 21f343f..719a21f 100644
--- a/divelist.c
+++ b/divelist.c
@@ -522,6 +522,9 @@ static void fill_one_dive(struct dive *dive,
 		DIVE_SAC, dive->sac,
 		DIVE_OTU, dive->otu,
 		-1);
+
+	free(location);
+	free(cylinder);
 }
 
 static gboolean set_one_dive(GtkTreeModel *model,
-- 
1.7.6.msysgit.0



More information about the subsurface mailing list