diff options
author | truebrain <truebrain@openttd.org> | 2009-03-07 20:55:24 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-03-07 20:55:24 +0000 |
commit | 3ca01c64f72b827076c2a76065749b1c1288b106 (patch) | |
tree | 12bfcb636aac5a931e8238e98a254b9b23841e2b /src | |
parent | 3adc0d77b86a085f5ce7acaccc23147d6ee33a59 (diff) | |
download | openttd-3ca01c64f72b827076c2a76065749b1c1288b106.tar.xz |
(svn r15638) -Fix: there is a time in your life you should stop coding for a project. You know that time is there when you make two huge mistakes in just 10 lines of code. I wish you all the best of luck :) (ps: HUGE mistakes!)
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_config.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp index 1cad24bb7..941fc8365 100644 --- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -204,9 +204,10 @@ void AIConfig::SettingsToString(char *string, size_t size) snprintf(no, sizeof(no), "%d", (*it).second); /* Check if the string would fit in the destination */ - size -= strlen((*it).first) - 1 - strlen(no) - 1; + size_t needed_size = strlen((*it).first) + 1 + strlen(no) + 1; /* If it doesn't fit, skip the next settings */ - if (size <= 0) return; + if (size <= needed_size) break; + size -= needed_size; strcat(string, (*it).first); strcat(string, "="); |