aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 55404319e..473a216bf 100644
--- a/src/settings.cpp
+++ b/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);
}