forked from Mirrorlandia_minetest/minetest
Settings: Fix crash on exit due to group double-free
This commit is contained in:
parent
49117de476
commit
e7f33ee2f1
@ -824,13 +824,21 @@ bool Settings::setDefault(const std::string &name, const std::string &value)
|
|||||||
|
|
||||||
bool Settings::setGroup(const std::string &name, Settings *group)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user