diff options
-rw-r--r-- | src/unicode/ntapi_uc_unicode_conversion_from_utf16.c | 12 | ||||
-rw-r--r-- | src/unicode/ntapi_uc_unicode_conversion_from_utf8.c | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c b/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c index bbb12d2..eb8196c 100644 --- a/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c +++ b/src/unicode/ntapi_uc_unicode_conversion_from_utf16.c @@ -270,10 +270,16 @@ int32_t __stdcall __ntapi_uc_convert_unicode_stream_utf16_to_utf8( params->bytes_written = args.bytes_written; - if (status) - status = __update_stream_leftover_info_utf16(params); + switch (status) { + case NT_STATUS_SUCCESS: + case NT_STATUS_BUFFER_TOO_SMALL: + return status; - /* the following bit shift will be optimized out on 32-bit architectures */ + default: + status = __update_stream_leftover_info_utf16(params); + } + + /* (optimized out on 32-bit architectures) */ params->leftover_bytes <<= (8 * (sizeof(uintptr_t) - sizeof(uint32_t))); return status; diff --git a/src/unicode/ntapi_uc_unicode_conversion_from_utf8.c b/src/unicode/ntapi_uc_unicode_conversion_from_utf8.c index 1ec6eb0..48eacb2 100644 --- a/src/unicode/ntapi_uc_unicode_conversion_from_utf8.c +++ b/src/unicode/ntapi_uc_unicode_conversion_from_utf8.c @@ -271,8 +271,14 @@ int32_t __stdcall __ntapi_uc_convert_unicode_stream_utf8_to_utf16( params->bytes_written = args.bytes_written; - if (status != NT_STATUS_SUCCESS) - status = __update_stream_leftover_info_utf8(params); + switch (status) { + case NT_STATUS_SUCCESS: + case NT_STATUS_BUFFER_TOO_SMALL: + return status; + + default: + status = __update_stream_leftover_info_utf8(params); + } /* (optimized out on 32-bit architectures) */ params->leftover_bytes <<= (8 * (sizeof(uintptr_t) - sizeof(uint32_t))); |