From 76d8b00ecc53ec637cb8f4fe6c276e97b3820aa1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 1 Sep 2016 11:54:28 -0400 Subject: [PATCH] core/playlists/library: Use library tag path when allocating playlists This isn't as important for established playlists, but this string could quickly become an invalid pointer for new playlists that are added. Signed-off-by: Anna Schumaker --- CHANGELOG | 1 + core/playlists/library.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index eb66527b..87069709 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 6.4.19: +- Fix memory corruption when adding new library playlists - Use Enter key to accept new library paths - Remove deleted tracks from artist playlists - File chooser selects user's music directory diff --git a/core/playlists/library.c b/core/playlists/library.c index 0891b6e0..797ccca2 100644 --- a/core/playlists/library.c +++ b/core/playlists/library.c @@ -16,11 +16,11 @@ static bool __lib_pl_scan_dir(void *); static struct queue_ops *lib_ops = NULL; -static struct playlist *__lib_pl_alloc(const gchar *path) +static struct playlist *__lib_pl_alloc(struct library *library) { struct playlist *playlist = g_malloc(sizeof(struct playlist)); - playlist->pl_name = path; + playlist->pl_name = library->li_path; playlist->pl_type = PL_LIBRARY; playlist_generic_init(playlist, Q_REPEAT, lib_ops); @@ -153,7 +153,7 @@ static bool pl_library_new(const gchar *name) return false; library = library_find(name); - library->li_playlist = __lib_pl_alloc(name); + library->li_playlist = __lib_pl_alloc(library); __lib_pl_scan_dir_idle(library, name); return true; @@ -223,7 +223,7 @@ static bool __lib_pl_init(void *data) struct playlist *playlist; db_for_each(dbe, next, library_db_get()) { - playlist = __lib_pl_alloc(LIBRARY(dbe)->li_path); + playlist = __lib_pl_alloc(LIBRARY(dbe)); LIBRARY(dbe)->li_playlist = playlist; idle_schedule(IDLE_SYNC, __lib_pl_load, playlist);