Skip to content

Fix out-of-bounds risks from random values

Tuomas Nurmi requested to merge nurmi/amarok:fixRandomMax into master

Previously implemented with deprecated qrand(), then ported to use QRandomGenerator::global()->generate(). Maximum value for qrand() was RAND_MAX, which was used for normalizing the random numbers. However, the max value for QRG->generate() is std::numeric_limits::max(), which might be more than RAND_MAX. At least on VirtualBox I used for testing, it was a lot more, causing random track selection to go out of bounds of options and crash almost every time when testing with a short playlist.

Merge request reports

Loading