[easytag/easytag-2-2] Fix two memory leaks in CDDB dialog
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/easytag-2-2] Fix two memory leaks in CDDB dialog
- Date: Mon, 20 Oct 2014 08:23:05 +0000 (UTC)
commit 6acef14540c698da483352ce8864be151f1dfda9
Author: David King <amigadave amigadave com>
Date: Wed Oct 8 19:31:18 2014 +0100
Fix two memory leaks in CDDB dialog
Store a pointer to the start of the GLists, so that the lists can be
freed later.
src/cddb.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/cddb.c b/src/cddb.c
index 3751250..80df26b 100644
--- a/src/cddb.c
+++ b/src/cddb.c
@@ -3030,7 +3030,9 @@ Cddb_Search_Album_From_Selected_Files (void)
num_tracks = file_selectedcount;
query_string = g_strdup("");
- for (l = g_list_reverse (file_iterlist); l != NULL; l = g_list_next (l))
+ file_iterlist = g_list_reverse (file_iterlist);
+
+ for (l = file_iterlist; l != NULL; l = g_list_next (l))
{
ET_File *etfile;
gulong secs = 0;
@@ -3761,10 +3763,16 @@ Cddb_Get_Album_Tracks_List (GtkTreeSelection* selection)
g_free(cddbtrackalbum);
}else
{
- if (TrackOffsetList && TrackOffsetList->next)
+ GList *l;
+
+ for (l = TrackOffsetList; l != NULL; l = g_list_next (l))
{
- cddbtrackalbum->duration = ( ((CddbTrackFrameOffset
*)TrackOffsetList->next->data)->offset - ((CddbTrackFrameOffset *)TrackOffsetList->data)->offset ) / 75; //
Calculate time in seconds
- TrackOffsetList = TrackOffsetList->next;
+ if (l->next)
+ {
+ cddbtrackalbum->duration = (((CddbTrackFrameOffset *)l->next->data)->offset
+ - ((CddbTrackFrameOffset *)l->data)->offset)
+ / 75; /* Calculate time in seconds. */
+ }
}
cddbalbum->track_list = g_list_append(cddbalbum->track_list,cddbtrackalbum);
}
@@ -3814,9 +3822,7 @@ Cddb_Get_Album_Tracks_List (GtkTreeSelection* selection)
Cddb_Show_Album_Info(gtk_tree_view_get_selection(GTK_TREE_VIEW(CddbAlbumListView)),NULL);
- // Frees 'TrackOffsetList'
g_list_free_full (TrackOffsetList, (GDestroyNotify)g_free);
- TrackOffsetList = NULL;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]