Skip to content
Browse files

Added additional bound checks to RNG.

  • Loading branch information...
1 parent e0a63ea commit a14fd96bdf2e489517c140190f6fea9821a26799 Mark Morschhäuser committed Mar 20, 2014
Showing with 2 additions and 2 deletions.
  1. +2 −2 gemrb/core/RNG/RNG_SFMT.cpp
View
4 gemrb/core/RNG/RNG_SFMT.cpp
@@ -90,8 +90,8 @@ RNG_SFMT* RNG_SFMT::getInstance() {
*/
unsigned int RNG_SFMT::rand(unsigned int min, unsigned int max) {
// This all makes no sense if min > max, which should never happen.
- if (min > max) {
- throw std::invalid_argument("Invalid bounds for RNG: min > max!");
+ if (min > max || max >= UINT_MAX || min >= UINT_MAX) {
+ throw std::invalid_argument("Invalid bounds for RNG!");
// at this point, the method exits. No return value is needed, because
// basically the exception itself is returned.
}

0 comments on commit a14fd96

Please sign in to comment.
Something went wrong with that request. Please try again.