From e96779de48be1f1b0080a8e1cfa89756c40e562d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Aug 2012 22:19:39 +0200 Subject: player_control: duplicate the song object Make sure the player "owns" the next_song object, so nobody else can free it. --- src/playlist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/playlist.c') diff --git a/src/playlist.c b/src/playlist.c index 4c95bc7ce..4d4f0c1f6 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -78,14 +78,15 @@ static void playlist_queue_song_order(struct playlist *playlist, struct player_control *pc, unsigned order) { - struct song *song; char *uri; assert(queue_valid_order(&playlist->queue, order)); playlist->queued = order; - song = queue_get_order(&playlist->queue, order); + struct song *song = + song_dup_detached(queue_get_order(&playlist->queue, order)); + uri = song_get_uri(song); g_debug("queue song %i:\"%s\"", playlist->queued, uri); g_free(uri); @@ -191,13 +192,13 @@ void playlist_play_order(struct playlist *playlist, struct player_control *pc, int orderNum) { - struct song *song; char *uri; playlist->playing = true; playlist->queued = -1; - song = queue_get_order(&playlist->queue, orderNum); + struct song *song = + song_dup_detached(queue_get_order(&playlist->queue, orderNum)); uri = song_get_uri(song); g_debug("play %i:\"%s\"", orderNum, uri); -- cgit v1.2.3