Skip to content

Commit

Permalink
Merge pull request #3742 from lethosor/fix-luaapi-tostring
Browse files Browse the repository at this point in the history
Fix unchecked lua_tostring calls
  • Loading branch information
myk002 authored Sep 6, 2023
2 parents 73df72c + 337260a commit 0bd0a82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/LuaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> entries;
ensureCommandHistory(id, src_file)->getEntries(entries);
Lua::PushVector(state, entries);
Expand Down Expand Up @@ -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<df::unit *> units;
Units::getUnitsByNobleRole(units, role_name);
Lua::PushVector(L, units);
Expand Down

0 comments on commit 0bd0a82

Please sign in to comment.