Fix crash in math.random if a max size interval is specified
This commit is contained in:
parent
53d573ad3c
commit
26a17c4e1f
@ -200,7 +200,16 @@ static int mathRandom(lua_State *l)
|
||||
{
|
||||
luaL_error(l, "interval is empty");
|
||||
}
|
||||
if (upper - lower + 1)
|
||||
{
|
||||
lua_pushinteger(l, rng.between(lower, upper));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The interval is *so* not empty that its size overflows 32-bit integers
|
||||
// (only possible if it's exactly 0x100000000); don't use between.
|
||||
lua_pushinteger(l, int(rng()));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user