summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-12-20 20:52:05 +0000
committerDarkvater <Darkvater@openttd.org>2005-12-20 20:52:05 +0000
commiteea9e9527865f365fd91f842c8ee192aa3caaa74 (patch)
treea8811c0d9f666534f8861378b0eb8b6629c5186b /string.c
parent63c24f25a77c87c75269af157c42efce5317844f (diff)
downloadopenttd-eea9e9527865f365fd91f842c8ee192aa3caaa74.tar.xz
(svn r3322) - Fix: Network window crash when it receives invalid information for example from the integrated nightly, so validate the network-input when it is received
- CodeChange: added str_validate(char *str) function that checks if a string contains only printable characters and if not, replaces those characters by question marks. Also move IsValidAsciiChar() to string.h
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/string.c b/string.c
index ee5f1152e..18428527d 100644
--- a/string.c
+++ b/string.c
@@ -57,3 +57,9 @@ char* CDECL str_fmt(const char* str, ...)
if (p != NULL) memcpy(p, buf, len + 1);
return p;
}
+
+void str_validate(char *str)
+{
+ for (; *str != '\0'; str++)
+ if (!IsValidAsciiChar(*str)) *str = '?';
+}