summaryrefslogtreecommitdiff
path: root/library/LuaApi.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-06-16 17:09:58 +0400
committerAlexander Gavrilov2012-06-16 17:09:58 +0400
commit927ce6ce5adf019fd4f5fe18024b4f1b4c17fc20 (patch)
tree64d1e934bc63db89a813af49805a082fac91c7bb /library/LuaApi.cpp
parentdb91850464a98e785ff53cfdc5df46b10229cfdb (diff)
downloaddfhack-927ce6ce5adf019fd4f5fe18024b4f1b4c17fc20.tar.gz
dfhack-927ce6ce5adf019fd4f5fe18024b4f1b4c17fc20.tar.bz2
dfhack-927ce6ce5adf019fd4f5fe18024b4f1b4c17fc20.tar.xz
Fix a problem with number to address cast for high-half addresses.
If the address is out of the signed int range, lua_tointeger produces unspecified result. lua_tounsigned is guaranteed to wrap.
Diffstat (limited to 'library/LuaApi.cpp')
-rw-r--r--library/LuaApi.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp
index 50458f11..cdfd4789 100644
--- a/library/LuaApi.cpp
+++ b/library/LuaApi.cpp
@@ -1028,7 +1028,7 @@ static void *checkaddr(lua_State *L, int idx, bool allow_null = false)
if (lua_isnil(L, idx))
rv = NULL;
else if (lua_type(L, idx) == LUA_TNUMBER)
- rv = (void*)lua_tointeger(L, idx);
+ rv = (void*)lua_tounsigned(L, idx);
else
rv = Lua::CheckDFObject(L, NULL, idx);
if (!rv && !allow_null)