aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-25 19:50:05 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-25 19:50:05 +0000
commit121e2063e07e70242700015a446586a84699dcfa (patch)
treec27463211c74bc845b5f4671021d909044e45f7c
parent90c75b1107605d6fb075a5bd0388052d693dd3bc (diff)
downloadmpd-121e2063e07e70242700015a446586a84699dcfa.tar.gz
mpd-121e2063e07e70242700015a446586a84699dcfa.tar.xz
mpd-121e2063e07e70242700015a446586a84699dcfa.zip
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
-rw-r--r--src/playlist.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/playlist.c b/src/playlist.c
index bd1d254b6..61679530a 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -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();