Skip to content

Commit bc0318d

Browse files
committedOct 26, 2015
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.
1 parent 306b067 commit bc0318d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

Diff for: ‎src/script/lua_api/l_noise.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ int LuaPseudoRandom::create_object(lua_State *L)
440440
{
441441
NO_MAP_LOCK_REQUIRED;
442442

443-
int seed = luaL_checknumber(L, 1);
443+
u64 seed = luaL_checknumber(L, 1);
444444
LuaPseudoRandom *o = new LuaPseudoRandom(seed);
445445
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
446446
luaL_getmetatable(L, className);
@@ -537,8 +537,8 @@ int LuaPcgRandom::create_object(lua_State *L)
537537
{
538538
NO_MAP_LOCK_REQUIRED;
539539

540-
lua_Integer seed = luaL_checknumber(L, 1);
541-
LuaPcgRandom *o = lua_isnumber(L, 2) ?
540+
u64 seed = luaL_checknumber(L, 1);
541+
LuaPcgRandom *o = lua_isnumber(L, 2) ?
542542
new LuaPcgRandom(seed, lua_tointeger(L, 2)) :
543543
new LuaPcgRandom(seed);
544544
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;

0 commit comments

Comments
 (0)