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 | 197245eefe096da8008ce8d4772ab51fd2fb5cf4 (patch) | |
tree | 9036d7981e0a89c94166c8e8be18e4a935578a61 | |
parent | 6ba71707f290e77a0fb3414aadb7e9e39636cdfd (diff) | |
download | openttd-197245eefe096da8008ce8d4772ab51fd2fb5cf4.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.
-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; } |