Fix check for string termination in IsValidUtf8String()

The current code incorrectly returned true if the string contained
an invalid UTF-8 sequence after an embedded NUL.

Check the entire string if the length was explicitly given instead of stopping
at the first NUL.

Closes https://github.com/wxWidgets/wxWidgets/pull/236
This commit is contained in:
ARATA Mizuki
2016-02-23 16:05:22 +09:00
committed by Vadim Zeitlin
parent e14b589e8e
commit a2f0374052
2 changed files with 9 additions and 1 deletions

View File

@@ -94,7 +94,7 @@ bool wxStringOperationsUtf8::IsValidUtf8String(const char *str, size_t len)
const unsigned char *c = (const unsigned char*)str;
const unsigned char * const end = (len == wxStringImpl::npos) ? NULL : c + len;
for ( ; c != end && *c; ++c )
for ( ; end != NULL ? c != end : *c; ++c )
{
unsigned char b = *c;