aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-10-26 04:01:01 -0400
committerkwolekr <kwolekr@minetest.net>2015-10-26 04:04:52 -0400
commitbc0318d2fc0d435e20b1186203ce2908162241ca (patch)
treed436daeb21ca767a07b00c931885e8fb08414e2a /src
parent306b0670916fee8d0316a69f161c7a9b14e9516d (diff)
downloadminetest-bc0318d2fc0d435e20b1186203ce2908162241ca.tar.gz
minetest-bc0318d2fc0d435e20b1186203ce2908162241ca.tar.bz2
minetest-bc0318d2fc0d435e20b1186203ce2908162241ca.zip
SAPI: Fix seed parameter truncation for LuaPseudoRandom constructor
Also fix a potential seed truncation issue on platforms where the range of ptrdiff_t (the underlying type of lua_Integer) is too small.
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_noise.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp
index 43dd32023..6dcffa31c 100644
--- a/src/script/lua_api/l_noise.cpp
+++ b/src/script/lua_api/l_noise.cpp
@@ -440,7 +440,7 @@ int LuaPseudoRandom::create_object(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- int seed = luaL_checknumber(L, 1);
+ u64 seed = luaL_checknumber(L, 1);
LuaPseudoRandom *o = new LuaPseudoRandom(seed);
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
luaL_getmetatable(L, className);
@@ -537,8 +537,8 @@ int LuaPcgRandom::create_object(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- lua_Integer seed = luaL_checknumber(L, 1);
- LuaPcgRandom *o = lua_isnumber(L, 2) ?
+ u64 seed = luaL_checknumber(L, 1);
+ LuaPcgRandom *o = lua_isnumber(L, 2) ?
new LuaPcgRandom(seed, lua_tointeger(L, 2)) :
new LuaPcgRandom(seed);
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;