Check length first in BUF_strnlen().

This commit is contained in:
Ben Laurie 2014-05-22 10:11:40 +01:00
parent 085ccc542a
commit eb33348879

View File

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