summaryrefslogtreecommitdiff
path: root/src/ai
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
commit61ee8ca42a5c4e6ddb541304cea471032a48a79a (patch)
treec8cb42ff00cff00c8394bf5865784239eabe7618 /src/ai
parent38afe1fe3fa7dc57ea7b62fd46a233cbba1f5c26 (diff)
downloadopenttd-61ee8ca42a5c4e6ddb541304cea471032a48a79a.tar.xz
(svn r15171) -Fix (r15027): Buffer underflow in case there are no settings to save for an AI.
Diffstat (limited to 'src/ai')
-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';
}