diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2012-10-02 01:52:44 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-10-01 20:56:17 -0700 |
commit | fa5afc697e664a93fc754e50dbfd15b2333028e7 (patch) | |
tree | e903089de879d46b5c55d1a644b5839add7fbc1d /gtk-gui.c | |
parent | cfefa0206dce3e144ee51383d81a146719b64737 (diff) | |
download | subsurface-fa5afc697e664a93fc754e50dbfd15b2333028e7.tar.gz |
Fix memory leaks related to dive_trip->location
When creating a new dive_trip from a dive, we should probably
always copy the location via strdup(). However we then have to take
care of the de-allocation in divelist.c:delete_trip()
and gtk-gui.c:file_close().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -251,6 +251,14 @@ static gboolean ask_save_changes() return quit; } +static void dive_trip_unref(gpointer data, gpointer user_data) +{ + dive_trip_t *dive_trip = (dive_trip_t *)data; + if (dive_trip->location) + free(dive_trip->location); + free(data); +} + static void file_close(GtkWidget *w, gpointer data) { int i; @@ -271,7 +279,7 @@ static void file_close(GtkWidget *w, gpointer data) mark_divelist_changed(FALSE); /* inlined version of g_list_free_full(dive_trip_list, free); */ - g_list_foreach(dive_trip_list, (GFunc)free, NULL); + g_list_foreach(dive_trip_list, (GFunc)dive_trip_unref, NULL); g_list_free(dive_trip_list); dive_trip_list = NULL; |