summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYexo <Yexo@openttd.org>2009-01-20 15:58:40 +0000
committerYexo <Yexo@openttd.org>2009-01-20 15:58:40 +0000
commit1f5b8c97df949f33cfd339aded85ea58aadb49ff (patch)
treec8cb42ff00cff00c8394bf5865784239eabe7618 /src
parent6e6bab2b45b8b4fd1965283d807a9a88b4ee72b4 (diff)
downloadopenttd-1f5b8c97df949f33cfd339aded85ea58aadb49ff.tar.xz
(svn r15171) -Fix (r15027): Buffer underflow in case there are no settings to save for an AI.
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_config.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp
index cd0cc8f30..dbae4bce0 100644
--- a/src/ai/ai_config.cpp
+++ b/src/ai/ai_config.cpp
@@ -208,5 +208,7 @@ void AIConfig::SettingsToString(char *string, int size)
strcat(string, no);
strcat(string, ",");
}
- string[strlen(string) - 1] = '\0';
+ /* Remove the last ',', but only if at least one setting was saved. */
+ size_t len = strlen(string);
+ if (len > 0) string[len - 1] = '\0';
}