diff options
author | SmallJoker <mk939@ymail.com> | 2020-09-22 18:40:34 +0200 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2020-09-22 19:05:04 +0200 |
commit | add68369a59af90f8b4203b53695521c6d657d6b (patch) | |
tree | a0014dc120d08775be67410e820a283a986593be /src/settings.cpp | |
parent | 55e2dd911b16a70ee976e067cf34a48922db9dcb (diff) | |
download | hax-minetest-server-add68369a59af90f8b4203b53695521c6d657d6b.tar.gz hax-minetest-server-add68369a59af90f8b4203b53695521c6d657d6b.zip |
Settings: Fix unittest memory leak, change input types
Diffstat (limited to '')
-rw-r--r-- | src/settings.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 473a216bf..28b72c4e3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -822,22 +822,22 @@ 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, const Settings &group) { // Settings must own the group pointer // avoid double-free by copying the source Settings *copy = new Settings(); - *copy = *group; + *copy = group; return setEntry(name, ©, true, false); } -bool Settings::setGroupDefault(const std::string &name, Settings *group) +bool Settings::setGroupDefault(const std::string &name, const Settings &group) { // Settings must own the group pointer // avoid double-free by copying the source Settings *copy = new Settings(); - *copy = *group; + *copy = group; return setEntry(name, ©, true, true); } @@ -1060,7 +1060,7 @@ void Settings::overrideDefaults(Settings *other) { for (const auto &setting : other->m_settings) { if (setting.second.is_group) { - setGroupDefault(setting.first, setting.second.group); + setGroupDefault(setting.first, *setting.second.group); continue; } const FlagDesc *flagdesc = getFlagDescFallback(setting.first); |