Check length first in BUF_strnlen().

This commit is contained in:
Ben Laurie 2014-05-22 10:11:40 +01:00
parent 15e4565984
commit d77501d8fd

View File

@ -64,7 +64,7 @@ size_t BUF_strnlen(const char *str, size_t maxlen)
{ {
const char *p; const char *p;
for (p = str; *p != '\0' && maxlen-- != 0; ++p) for (p = str; maxlen-- != 0 && *p != '\0'; ++p)
; ;
return p - str; return p - str;