diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/settings.cpp | 12 |
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, ©, 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, ©, true, true); } |