fix for floating point exception when adding randomly to the playlist with

only one thing in the playlist or playing the last song in the playlist

git-svn-id: https://svn.musicpd.org/mpd/trunk@1162 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-05-25 19:50:05 +00:00
parent 90c75b1107
commit 121e2063e0

View File

@ -505,9 +505,11 @@ int addSongToPlaylist(FILE * fp, Song * song) {
/*if(playlist_state==PLAYLIST_STATE_STOP) start = 0;
else */if(playlist.queued>=0) start = playlist.queued+1;
else start = playlist.current+1;
swap = rand()%(playlist.length-start);
swap+=start;
swapOrder(playlist.length-1,swap);
if(start < playlist.length) {
swap = rand()%(playlist.length-start);
swap+=start;
swapOrder(playlist.length-1,swap);
}
}
incrPlaylistVersion();