Skip to content

Commit

Permalink
Settings: Prevent mutex deadlock in remove() (#7803)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker committed Sep 18, 2019
1 parent 94a5df7 commit 4271889
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/settings.cpp
Expand Up @@ -908,17 +908,20 @@ bool Settings::setNoiseParams(const std::string &name,

bool Settings::remove(const std::string &name)
{
MutexAutoLock lock(m_mutex);
// Lock as short as possible, unlock before doCallbacks()
m_mutex.lock();

SettingEntries::iterator it = m_settings.find(name);
if (it != m_settings.end()) {
delete it->second.group;
m_settings.erase(it);
m_mutex.unlock();

doCallbacks(name);
return true;
}

m_mutex.unlock();
return false;
}

Expand Down

0 comments on commit 4271889

Please sign in to comment.