From 121e2063e07e70242700015a446586a84699dcfa Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Tue, 25 May 2004 19:50:05 +0000 Subject: 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 --- src/playlist.c | 8 +++++--- 1 file 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(); -- cgit v1.2.3