diff options
author | rubidium <rubidium@openttd.org> | 2007-07-14 22:37:40 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-14 22:37:40 +0000 |
commit | c598d1b446ba8902d7070f7d7ba137fc8edf2e96 (patch) | |
tree | 9036d7981e0a89c94166c8e8be18e4a935578a61 /src | |
parent | 0ee2bb60bd7d6ee4be7db2ae224e8765dc8c5403 (diff) | |
download | openttd-c598d1b446ba8902d7070f7d7ba137fc8edf2e96.tar.xz |
(svn r10566) -Fix [FS#1025]: a NewGRF could have a information message that is too long for the internal buffers to handle. We should not crash on such a case even though the message is too big for the window anyway.
Diffstat (limited to 'src')
-rw-r--r-- | src/string.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/string.cpp b/src/string.cpp index b13378b2a..12e6b5823 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -9,6 +9,7 @@ #include "macros.h" #include "table/control_codes.h" #include "helpers.hpp" +#include "debug.h" #include <stdarg.h> #include <ctype.h> // required for tolower() @@ -47,11 +48,14 @@ char* strecpy(char* dst, const char* src, const char* last) assert(dst <= last); for (; *src != '\0' && dst != last; ++dst, ++src) *dst = *src; *dst = '\0'; -#if 1 if (dst == last && *src != '\0') { +#ifdef STRGEN error("String too long for destination buffer"); +#else /* STRGEN */ + DEBUG(misc, 0, "String too long for destination buffer"); + *dst = '\0'; +#endif /* STRGEN */ } -#endif return dst; } |