Skip to content

Commit da2785b

Browse files
Ahmed Shehab (Si-Vision)keith-packard
authored andcommitted
stdlib: mbtowc() function can't return -2
mbtowc() function can only return the number of bytes consumed to convert a valid multibyte character or 0 if the input points to a null character or -1 if the input points to an invalid multibyte sequence. before this change, if _MBTOWC call is __ascii_mbtowc() and n = 0 it will return -2 in retval and the mbtowc return the retval as it is which is non-standard it should return -1 if the conversion is invalid which is the case with n = 0 Signed-off-by: Ahmed Shehab <[email protected]>
1 parent 8e84dee commit da2785b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

newlib/libc/stdlib/mbtowc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ mbtowc (wchar_t *__restrict pwc,
6464
int retval;
6565

6666
retval = __MBTOWC (pwc, s, n, ps);
67-
if (retval == -1) {
67+
if (retval < 0) {
6868
#ifdef _MB_CAPABLE
6969
_mbtowc_state.__count = 0;
7070
#endif

0 commit comments

Comments
 (0)