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