Skip to content

Commit 64df6c6

Browse files
committed
GetVector: check that item is a table before iterating
This fixes many crashes in API functions that used GetVector() without this check
1 parent 07ad3a2 commit 64df6c6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

library/LuaTools.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void DFHack::Lua::Push(lua_State *state, const df::coord2d &pos)
122122

123123
void DFHack::Lua::GetVector(lua_State *state, std::vector<std::string> &pvec, int idx)
124124
{
125+
luaL_checktype(state, idx, LUA_TTABLE);
125126
lua_pushnil(state); // first key
126127
while (lua_next(state, idx) != 0)
127128
{

0 commit comments

Comments
 (0)