crt: avoid sign-extension of argument to isleadbyte in mbrtowc
Passing an argument of type `char` to isleadbyte may result in
sign-extension of its argument. crtdll.dll's isleadbyte does not
handle sign-extended input properly, which result in incorrect
behavior of mbrlen and mbrtowc functions.
Add cast to `unsigned char` to avoid this.
Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/misc/mbrtowc.c b/mingw-w64-crt/misc/mbrtowc.c
index 75c9f98..ba0b9c0 100644
--- a/mingw-w64-crt/misc/mbrtowc.c
+++ b/mingw-w64-crt/misc/mbrtowc.c
@@ -75,7 +75,7 @@
conversion_state.bytes[1] = mbs[0];
bytes_consumed = 1;
length = 2;
- } else if (mb_cur_max == 2 && isleadbyte (mbs[0])) {
+ } else if (mb_cur_max == 2 && isleadbyte ((unsigned char) mbs[0])) {
conversion_state.bytes[0] = mbs[0];
/* We need to examine mbs[1] */