summaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-14 22:37:40 +0000
committerrubidium <rubidium@openttd.org>2007-07-14 22:37:40 +0000
commit197245eefe096da8008ce8d4772ab51fd2fb5cf4 (patch)
tree9036d7981e0a89c94166c8e8be18e4a935578a61 /src/string.cpp
parent6ba71707f290e77a0fb3414aadb7e9e39636cdfd (diff)
downloadopenttd-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.
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp8
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;
}