Skip to content

Commit d040a3f

Browse files
authored
Merge pull request #4678 from lethosor/threadsafe-mortal-cpp
Fix thread-safety issues around armok mode logic
2 parents 635f143 + 64df6c6 commit d040a3f

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

library/Core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,10 +2382,12 @@ void Core::setSuppressDuplicateKeyboardEvents(bool suppress) {
23822382
}
23832383

23842384
void Core::setMortalMode(bool value) {
2385+
std::lock_guard<std::mutex> lock(HotkeyMutex);
23852386
mortal_mode = value;
23862387
}
23872388

23882389
void Core::setArmokTools(const std::vector<std::string> &tool_names) {
2390+
std::lock_guard<std::mutex> lock(HotkeyMutex);
23892391
armok_tools.clear();
23902392
armok_tools.insert(tool_names.begin(), tool_names.end());
23912393
}

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)