[easytag] Fix two memory leaks in CDDB dialog
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Fix two memory leaks in CDDB dialog
- Date: Wed, 8 Oct 2014 20:20:51 +0000 (UTC)
commit 75c025779d7992b2ddfb89f47a04d80ad2a0ce35
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_dialog.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index 583d6f8..584136f 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -1146,10 +1146,16 @@ Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, 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);
}
@@ -1198,9 +1204,7 @@ Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection)
show_album_info (self, gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->album_list_view)));
- // Frees 'TrackOffsetList'
g_list_free_full (TrackOffsetList, (GDestroyNotify)g_free);
- TrackOffsetList = NULL;
return TRUE;
}
@@ -3266,7 +3270,9 @@ et_cddb_dialog_search_from_selection (EtCDDBDialog *self)
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]