mpd: fix floating point exception when adding random tags/songs
This commit is contained in:
committed by
Andrzej Rybczak
parent
9888c3106e
commit
af17e7eadf
@@ -505,7 +505,7 @@ bool Connection::AddRandomTag(mpd_tag_type tag, size_t number)
|
||||
else
|
||||
{
|
||||
std::random_shuffle(tags.begin(), tags.end());
|
||||
auto it = tags.begin()+rand()%(tags.size()-number);
|
||||
auto it = tags.begin();
|
||||
for (size_t i = 0; i < number && it != tags.end(); ++i)
|
||||
{
|
||||
StartSearch(1);
|
||||
@@ -546,7 +546,7 @@ bool Connection::AddRandomSongs(size_t number)
|
||||
{
|
||||
std::random_shuffle(files.begin(), files.end());
|
||||
StartCommandsList();
|
||||
auto it = files.begin()+rand()%(std::max(size_t(1), files.size()-number));
|
||||
auto it = files.begin();
|
||||
for (size_t i = 0; i < number && it != files.end(); ++i, ++it)
|
||||
AddSong(*it);
|
||||
CommitCommandsList();
|
||||
|
||||
Reference in New Issue
Block a user