diff options
author | midipix <writeonce@midipix.org> | 2019-08-29 04:13:11 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2019-08-29 04:13:11 +0000 |
commit | 037eededf5ded2062da4f2668765b77fdd25960f (patch) | |
tree | a40bd54ccca23b518565c7e70835ece97fd722be | |
parent | f96e1d2fa751d70baccb09fcbc052ea59854d685 (diff) | |
download | ntapi-037eededf5ded2062da4f2668765b77fdd25960f.tar.bz2 ntapi-037eededf5ded2062da4f2668765b77fdd25960f.tar.xz |
__ntapi_tt_array_convert_utf16_to_utf8(): ubound accounts for null termination.
-rw-r--r-- | src/argv/ntapi_tt_array_utf16.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/argv/ntapi_tt_array_utf16.c b/src/argv/ntapi_tt_array_utf16.c index 540a7c1..6235606 100644 --- a/src/argv/ntapi_tt_array_utf16.c +++ b/src/argv/ntapi_tt_array_utf16.c @@ -169,16 +169,15 @@ int32_t __stdcall __ntapi_tt_array_convert_utf16_to_utf8( wchar16_t u_high; ptrdiff_t diff; - #define __UTF8_MAX_CODE_POINT_BYTES (4) - ch = (uint8_t *)buffer; - ubound = (uint8_t *)buffer + buffer_len - __UTF8_MAX_CODE_POINT_BYTES; + ubound = (uint8_t *)buffer + buffer_len - 5; diff = (uintptr_t)base / sizeof(wchar16_t); while (warrv && *warrv) { *arrv = (char *)(ch-(uintptr_t)base); wch = *warrv + diff; + /* ubound already accounts for null termination, see above */ while (*wch && (ch < ubound)) { if (*wch <= 0x7F) { /* from: 00000000 0xxxxxxx (little endian) */ |