diff --git a/libc/bionic/wchar.cpp b/libc/bionic/wchar.cpp index a507808f0..021d14b47 100644 --- a/libc/bionic/wchar.cpp +++ b/libc/bionic/wchar.cpp @@ -250,6 +250,9 @@ size_t wcsrtombs(char* dst, const wchar_t** src, size_t n, mbstate_t* /*ps*/) { // TODO: UTF-8 support. if ((*src)[i] > 0x7f) { errno = EILSEQ; + if (dst != NULL) { + *src = &(*src)[i]; + } return static_cast(-1); } if (dst != NULL) { diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp index 0a63b0017..d5d27ed75 100644 --- a/tests/wchar_test.cpp +++ b/tests/wchar_test.cpp @@ -58,8 +58,8 @@ TEST(wchar, wctomb_wcrtomb) { } TEST(wchar, wcstombs_wcrtombs) { - wchar_t chars[] = { L'h', L'e', L'l', L'l', L'o', 0 }; - wchar_t bad_chars[] = { L'h', L'i', 666, 0 }; + const wchar_t chars[] = { L'h', L'e', L'l', L'l', L'o', 0 }; + const wchar_t bad_chars[] = { L'h', L'i', 666, 0 }; const wchar_t* src; char bytes[BUFSIZ];