aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-27 22:56:25 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-27 22:59:09 -0700
commitc3acecd70808dc38807f4e9ae075d14d82cdb4a7 (patch)
tree9e61f93f5d3df1c2dd3714bde6525147737919e9 /src
parent407cefe8e1cead36129425a324629192e06f974d (diff)
downloadmpd-c3acecd70808dc38807f4e9ae075d14d82cdb4a7.tar.gz
mpd-c3acecd70808dc38807f4e9ae075d14d82cdb4a7.tar.xz
mpd-c3acecd70808dc38807f4e9ae075d14d82cdb4a7.zip
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().
Diffstat (limited to 'src')
-rw-r--r--src/playlist.c3
1 files changed, 2 insertions, 1 deletions
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)));