summaryrefslogtreecommitdiff
path: root/library/LuaWrapper.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/LuaWrapper.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/LuaWrapper.cpp')
-rw-r--r--library/LuaWrapper.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/LuaWrapper.cpp b/library/LuaWrapper.cpp
index 7c15a27a..9f2fc2f1 100644
--- a/library/LuaWrapper.cpp
+++ b/library/LuaWrapper.cpp
@@ -715,7 +715,7 @@ static int meta_reinterpret_cast(lua_State *state)
if (lua_isnil(state, 2))
ptr = NULL;
else if (lua_isnumber(state, 2))
- ptr = (void*)lua_tointeger(state, 2);
+ ptr = (void*)lua_tounsigned(state, 2);
else
{
ptr = get_object_internal(state, NULL, 2, false, true);