diff --git a/lib/libc/locale/ascii.c b/lib/libc/locale/ascii.c index 784814d2664d..a70d71a7b88c 100644 --- a/lib/libc/locale/ascii.c +++ b/lib/libc/locale/ascii.c @@ -143,6 +143,7 @@ _ascii_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src, nchr = 0; while (len-- > 0 && nms-- > 0) { if (*s & 0x80) { + *src = s; errno = EILSEQ; return ((size_t)-1); } @@ -177,6 +178,7 @@ _ascii_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, nchr = 0; while (len-- > 0 && nwc-- > 0) { if (*s < 0 || *s > 127) { + *src = s; errno = EILSEQ; return ((size_t)-1); } diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c index c4695fd1222a..4e5a61d99540 100644 --- a/lib/libc/locale/none.c +++ b/lib/libc/locale/none.c @@ -174,6 +174,7 @@ _none_wcsnrtombs(char * __restrict dst, const wchar_t ** __restrict src, nchr = 0; while (len-- > 0 && nwc-- > 0) { if (*s < 0 || *s > UCHAR_MAX) { + *src = s; errno = EILSEQ; return ((size_t)-1); }