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 <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-29 14:48:43 -04:00
parent cb2af114c5
commit 4250757b83
2 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -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);