summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-07 22:34:09 +0000
committermidipix <writeonce@midipix.org>2016-11-07 22:40:58 -0500
commit56548d7e7fd4703a3782c76dd08e4118a42cf7d5 (patch)
treef81b463169e06bb36c66afd99be82b3ee687aed9 /src
parent6eaf4a1e0e75c95ac1ab00edcdce35291777abb0 (diff)
downloadntapi-56548d7e7fd4703a3782c76dd08e4118a42cf7d5.tar.bz2
ntapi-56548d7e7fd4703a3782c76dd08e4118a42cf7d5.tar.xz
unicode converstion functions: properly forward NT_STATUS_BUFFER_TOO_SMALL;
Diffstat (limited to 'src')
-rw-r--r--src/unicode/ntapi_uc_unicode_conversion_from_utf16.c12
-rw-r--r--src/unicode/ntapi_uc_unicode_conversion_from_utf8.c10
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)));