fix bug #3424 (crash when adding amount of random songs equal to total number of songs)
This commit is contained in:
@@ -951,7 +951,7 @@ bool MPD::Connection::AddRandomSongs(size_t number)
|
||||
srand(time(0));
|
||||
std::random_shuffle(files.begin(), files.end());
|
||||
StartCommandsList();
|
||||
TagList::const_iterator it = files.begin()+rand()%(files.size()-number);
|
||||
TagList::const_iterator it = files.begin()+rand()%(std::max(size_t(1), files.size()-number));
|
||||
for (size_t i = 0; i < number && it != files.end(); ++i)
|
||||
AddSong(*it++);
|
||||
CommitCommandsList();
|
||||
|
||||
Reference in New Issue
Block a user