From 4250757b83d805d63710e4d46be9e7c86cb70c74 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 29 Sep 2016 14:48:43 -0400 Subject: [PATCH] core/playlists: Don't leak playlist names while loading We need to free the playlist name after looking up in case we hit the case where the playlist isn't found. Signed-off-by: Anna Schumaker --- core/playlists/artist.c | 3 ++- core/playlists/library.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/playlists/artist.c b/core/playlists/artist.c index 30a9c239..3b54be59 100644 --- a/core/playlists/artist.c +++ b/core/playlists/artist.c @@ -63,12 +63,13 @@ static bool __artist_pl_load(void *data) for (i = 0; i < n; i++) { name = file_readl(&artist_file); playlist = __artist_pl_lookup(name); + g_free(name); + if (!playlist) continue; queue_load_flags(&playlist->pl_queue, &artist_file, true); queue_iter_set(&playlist->pl_queue, &playlist->pl_queue.q_cur, playlist->pl_queue.q_cur.it_pos); - g_free(name); } file_close(&artist_file); diff --git a/core/playlists/library.c b/core/playlists/library.c index 6a19784d..8a918cf0 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -71,12 +71,13 @@ static bool __lib_pl_load(void *data) for (i = 0; i < n; i++) { name = file_readl(&lib_file); playlist = __lib_pl_lookup(name); + g_free(name); + if (!playlist) continue; queue_load_flags(&playlist->pl_queue, &lib_file, true); queue_iter_set(&playlist->pl_queue, &playlist->pl_queue.q_cur, playlist->pl_queue.q_cur.it_pos); - g_free(name); } file_close(&lib_file);