(svn r14204) -Fix (r7475): when determining length of a string with limited size, first check if we are not out of bounds already
authorsmatz
Sun, 31 Aug 2008 17:34:03 +0000
changeset 10044 a324ba35da2e
parent 10043 7f8f7df729d3
child 10045 af9efbc35972
(svn r14204) -Fix (r7475): when determining length of a string with limited size, first check if we are not out of bounds already
src/string_func.h
--- a/src/string_func.h	Sun Aug 31 16:41:27 2008 +0000
+++ b/src/string_func.h	Sun Aug 31 17:34:03 2008 +0000
@@ -48,7 +48,7 @@
 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;
 }