From 02ff3291bdfc8e7f3e75306204e18fe94aa39fa6 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 4 Jan 2016 12:15:14 +0200 Subject: [PATCH] Fixed division by zero in RNG Random number generator now returns zero for range [0, 0) --- src/m_random.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m_random.h b/src/m_random.h index b5e21c63c..452ef41fc 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -57,7 +57,9 @@ public: // Returns a random number in the range [0,mod) int operator() (int mod) { - return GenRand32() % mod; + return (0 == mod) + ? 0 + : (GenRand32() % mod); } // Returns rand# - rand#