mirror of https://github.com/OpenTTD/OpenTTD
(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!)
parent
3adc0d77b8
commit
3ca01c64f7
|
@ -204,9 +204,10 @@ void AIConfig::SettingsToString(char *string, size_t size)
|
||||||
snprintf(no, sizeof(no), "%d", (*it).second);
|
snprintf(no, sizeof(no), "%d", (*it).second);
|
||||||
|
|
||||||
/* Check if the string would fit in the destination */
|
/* 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 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, (*it).first);
|
||||||
strcat(string, "=");
|
strcat(string, "=");
|
||||||
|
|
Loading…
Reference in New Issue