summaryrefslogtreecommitdiffstats
path: root/libcxx/src/support
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2019-01-23 18:27:22 +0000
committerMarshall Clow <mclow.lists@gmail.com>2019-01-23 18:27:22 +0000
commit8681a3bc85def13aee9d8fac2d05e602bd4ece55 (patch)
treeed9527030b41ee473ebe554f8474c31175a39362 /libcxx/src/support
parentaa0e74c1fc62ed17299ef758f2d73ee19ff8cbe3 (diff)
downloadbcm5719-llvm-8681a3bc85def13aee9d8fac2d05e602bd4ece55.tar.gz
bcm5719-llvm-8681a3bc85def13aee9d8fac2d05e602bd4ece55.zip
Commit D11348: 'Win32 support: wcsnrtombs and mbsnrtowcs don't handle null output buffers correctly' which has been hanging around for a long time
llvm-svn: 351971
Diffstat (limited to 'libcxx/src/support')
-rw-r--r--libcxx/src/support/win32/support.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libcxx/src/support/win32/support.cpp b/libcxx/src/support/win32/support.cpp
index b4f1e22f3c6..4c9a4b3a507 100644
--- a/libcxx/src/support/win32/support.cpp
+++ b/libcxx/src/support/win32/support.cpp
@@ -61,6 +61,11 @@ size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
size_t result = 0;
bool have_result = false;
+ // If dst is null then max_dest_chars should be ignored according to the
+ // standard. Setting max_dest_chars to a large value has this effect.
+ if (!dst)
+ max_dest_chars = static_cast<size_t>(-1);
+
while ( source_remaining ) {
if ( dst && dest_converted >= max_dest_chars )
break;
@@ -114,6 +119,11 @@ size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
bool have_result = false;
bool terminator_found = false;
+ // If dst is null then dst_size_bytes should be ignored according to the
+ // standard. Setting dest_remaining to a large value has this effect.
+ if (!dst)
+ dest_remaining = static_cast<size_t>(-1);
+
while ( source_converted != max_source_chars ) {
if ( ! dest_remaining )
break;
OpenPOWER on IntegriCloud