Skip to content
Permalink
Browse files

Settings: Fix crash on exit due to group double-free

  • Loading branch information
SmallJoker committed Sep 21, 2020
1 parent 49117de commit e7f33ee2f1c57b2b5c48d1a54a5f9e4c72a3275c
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/settings.cpp
@@ -824,13 +824,21 @@ bool Settings::setDefault(const std::string &name, const std::string &value)

bool Settings::setGroup(const std::string &name, Settings *group)
{
return setEntry(name, &group, true, false);
// Settings must own the group pointer
// avoid double-free by copying the source
Settings *copy = new Settings();
*copy = *group;
return setEntry(name, &copy, true, false);
}


bool Settings::setGroupDefault(const std::string &name, Settings *group)
{
return setEntry(name, &group, true, true);
// Settings must own the group pointer
// avoid double-free by copying the source
Settings *copy = new Settings();
*copy = *group;
return setEntry(name, &copy, true, true);
}


0 comments on commit e7f33ee

Please sign in to comment.
You can’t perform that action at this time.