[libcxx] r351971 - Commit D11348: 'Win32 support: wcsnrtombs and mbsnrtowcs don't handle null output buffers correctly' which has been hanging around for a long time

Marshall Clow mclow.lists at gmail.com
Wed Jan 23 10:27:22 PST 2019


Author: marshall
Date: Wed Jan 23 10:27:22 2019
New Revision: 351971

URL: http://llvm.org/viewvc/llvm-project?rev=351971&view=rev
Log:
Commit D11348: 'Win32 support: wcsnrtombs and mbsnrtowcs don't handle null output buffers correctly' which has been hanging around for a long time

Modified:
    libcxx/trunk/src/support/win32/support.cpp

Modified: libcxx/trunk/src/support/win32/support.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/win32/support.cpp?rev=351971&r1=351970&r2=351971&view=diff
==============================================================================
--- libcxx/trunk/src/support/win32/support.cpp (original)
+++ libcxx/trunk/src/support/win32/support.cpp Wed Jan 23 10:27:22 2019
@@ -61,6 +61,11 @@ size_t mbsnrtowcs( wchar_t *__restrict d
     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,
     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;




More information about the libcxx-commits mailing list