summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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';
}