aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorwillcl-ark <will@256k1.dev>2023-03-09 22:25:01 +0000
committerwillcl-ark <will@256k1.dev>2023-03-09 23:24:06 +0000
commit8fcbdadfad8a9b3143527141ff37e5fe1e87f3b3 (patch)
treefd1b4f4efd52742bdde34c03e8eeefb60c86d893 /src/util
parentf7bdcfc83f5753349018be3b5a663c8923d1a5eb (diff)
util: fix argsman dupe key error
fixes #22638 If we find a duplicate key and error, clear `values` before returning so that WriteSettings will write an empty file, therefore clearing it. This aligns with GUI behaviour added in 1ee6d0b.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/settings.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util/settings.cpp b/src/util/settings.cpp
index 2b25b7f0e1..a2e30098dc 100644
--- a/src/util/settings.cpp
+++ b/src/util/settings.cpp
@@ -99,6 +99,8 @@ bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& va
auto inserted = values.emplace(in_keys[i], in_values[i]);
if (!inserted.second) {
errors.emplace_back(strprintf("Found duplicate key %s in settings file %s", in_keys[i], fs::PathToString(path)));
+ values.clear();
+ break;
}
}
return errors.empty();