summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Guilloux <glx22@users.noreply.github.com>2022-01-04 22:12:05 +0100
committerGitHub <noreply@github.com>2022-01-04 22:12:05 +0100
commitd62c5667cff2eed82deb18e28d98345500b30d3f (patch)
tree22ca9a197ef71d904e78148023db4baf89220e37
parent57b992717b5234fa1878567c8ff8907964f1abde (diff)
downloadopenttd-d62c5667cff2eed82deb18e28d98345500b30d3f.tar.xz
Fix #9766: Don't write uninitialised data in config file (#9767)
-rw-r--r--src/settings.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index f61976028..4decfecf3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -357,6 +357,10 @@ void OneOfManySettingDesc::FormatValue(char *buf, const char *last, const void *
void ManyOfManySettingDesc::FormatValue(char *buf, const char *last, const void *object) const
{
uint bitmask = (uint)this->Read(object);
+ if (bitmask == 0) {
+ buf[0] = '\0';
+ return;
+ }
bool first = true;
for (uint id : SetBitIterator(bitmask)) {
if (!first) buf = strecpy(buf, "|", last);