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); }