From c3acecd70808dc38807f4e9ae075d14d82cdb4a7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 27 Aug 2008 22:56:25 -0700 Subject: playlist: fix deleting the last song in a playlist unK reported a bug in which explicitly calling "delete" on each song would cause mpd to lock up. This is actually triggered when the only song on the mpd playlist is deleted. Additionally, add an extra assertion to ensure we play a valid, non-NULL song in play_order_num(). --- src/playlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/playlist.c') diff --git a/src/playlist.c b/src/playlist.c index 48db355a8..9751eda76 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -833,7 +833,7 @@ int deleteFromPlaylist(int fd, int song) } if (stop_current) { /* DEBUG(__FILE__": %d\n", __LINE__); */ - if (playlist.current >= 0) + if (playlist.current >= 0 && songOrder > 0) play_order_num(fd, playlist.current, 0); else stopPlaylist(fd); @@ -894,6 +894,7 @@ static int play_order_num(int fd, int order_num, float seek_time) playlist_state = PLAYLIST_STATE_PLAY; assert(order_num >= 0); assert(seek_time >= 0); + assert(song_at(order_num)); DEBUG("playlist: play %i:\"%s\"\n", order_num, get_song_url(path, song_at(order_num))); -- cgit v1.2.3