utf8_functions.h: Fix PVS 359

Fix integer constant SIZE_MAX is converted to pointer.

Change-Id: Ifdff4e08a9b2c31e466580ba9a71f6ea7c0191d4
Reviewed-on: https://review.haiku-os.org/c/865
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Murai Takashi 2019-01-08 21:07:26 +09:00 committed by waddlesplash
parent 5bfdd10fb6
commit 647b5a29e9

View File

@ -141,15 +141,17 @@ UTF8CountChars(const char *bytes, int32 numBytes)
return 0;
uint32 length = 0;
const char *last;
if (numBytes < 0)
last = (const char *)SIZE_MAX;
else
last = bytes + numBytes - 1;
while (bytes[0] && bytes <= last) {
if ((bytes++[0] & 0xc0) != 0x80)
length++;
if (numBytes < 0) {
while (bytes[0]) {
if ((bytes++[0] & 0xc0) != 0x80)
length++;
}
} else {
const char *last = bytes + numBytes - 1;
while (bytes[0] && bytes <= last) {
if ((bytes++[0] & 0xc0) != 0x80)
length++;
}
}
return length;