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:
committed by
Vadim Zeitlin
parent
e14b589e8e
commit
a2f0374052
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user