From 337260ab0c201f0328d75914214723feddeb908d Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 6 Sep 2023 18:19:31 -0400 Subject: [PATCH] Fix unchecked lua_tostring calls --- library/LuaApi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 1e89d7b45..f792cff90 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1368,8 +1368,8 @@ static CommandHistory * ensureCommandHistory(std::string id, static int getCommandHistory(lua_State *state) { - std::string id = lua_tostring(state, 1); - std::string src_file = lua_tostring(state, 2); + std::string id = luaL_checkstring(state, 1); + std::string src_file = luaL_checkstring(state, 2); std::vector entries; ensureCommandHistory(id, src_file)->getEntries(entries); Lua::PushVector(state, entries); @@ -2030,7 +2030,7 @@ static int units_getCitizens(lua_State *L) { } static int units_getUnitsByNobleRole(lua_State *L) { - std::string role_name = lua_tostring(L, -1); + std::string role_name = luaL_checkstring(L, -1); std::vector units; Units::getUnitsByNobleRole(units, role_name); Lua::PushVector(L, units);