summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-08-31 17:34:03 +0000
committersmatz <smatz@openttd.org>2008-08-31 17:34:03 +0000
commit6e5cc48c3475cd1ee2033707f65881fc93a59593 (patch)
tree4cba4e9575d336e1c7246864372c3613f9f90625 /src
parent4b53c92be229b323e296c02c757b5103b30bb4c1 (diff)
downloadopenttd-6e5cc48c3475cd1ee2033707f65881fc93a59593.tar.xz
(svn r14204) -Fix (r7475): when determining length of a string with limited size, first check if we are not out of bounds already
Diffstat (limited to 'src')
-rw-r--r--src/string_func.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string_func.h b/src/string_func.h
index 0a6ff6d28..1453170ad 100644
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -48,7 +48,7 @@ static inline bool StrEmpty(const char *s) { return s == NULL || s[0] == '\0'; }
static inline size_t ttd_strnlen(const char *str, size_t maxlen)
{
const char *t;
- for (t = str; *t != '\0' && (size_t)(t - str) < maxlen; t++) {}
+ for (t = str; (size_t)(t - str) < maxlen && *t != '\0'; t++) {}
return t - str;
}