aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-07-27 19:03:15 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-07-27 19:03:15 +0300
commite64feefc61e0fd104bfc40c61411b67423734924 (patch)
tree64a24b45e272b4a9671d85285d8b89e96855938e
parent3e754382af5d57b20fc2f6d59f991c9a79ccb0f7 (diff)
downloadminetest-e64feefc61e0fd104bfc40c61411b67423734924.tar.gz
minetest-e64feefc61e0fd104bfc40c61411b67423734924.tar.bz2
minetest-e64feefc61e0fd104bfc40c61411b67423734924.zip
Handle max<min in LuaPseudoRandom::l_next()
-rw-r--r--src/scriptapi.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 61488abb4..b8b3cb73a 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -3928,6 +3928,10 @@ private:
min = luaL_checkinteger(L, 2);
if(!lua_isnil(L, 3))
max = luaL_checkinteger(L, 3);
+ if(max < min){
+ errorstream<<"PseudoRandom.next(): max="<<max<<" min="<<min<<std::endl;
+ throw LuaError(L, "PseudoRandom.next(): max < min");
+ }
if(max - min != 32767 && max - min > 32767/5)
throw LuaError(L, "PseudoRandom.next() max-min is not 32767 and is > 32768/5. This is disallowed due to the bad random distribution the implementation would otherwise make.");
PseudoRandom &pseudo = o->m_pseudo;