On Fri, 25 Jul 2025, LIU Hao wrote:
When `wcrtomb()` is called with a null wide character (second argument) it is
required to output a sequence of bytes to 'restore the initial shift state'.
For this function, the `mbstate_t` structure shall be initialized before the
call.
Previous code passed an uninitialized structure and expected `wcrtomb(buf,
L'\0', &state)` to initialize `state` to the initial shift state, which was
incorrect.
Signed-off-by: LIU Hao <[email protected]>
---
mingw-w64-crt/stdio/mingw_pformat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-crt/stdio/mingw_pformat.c
b/mingw-w64-crt/stdio/mingw_pformat.c
index d094e7ace..4e41b4d82 100644
--- a/mingw-w64-crt/stdio/mingw_pformat.c
+++ b/mingw-w64-crt/stdio/mingw_pformat.c
@@ -569,8 +569,8 @@ void __pformat_wputchars( const wchar_t *s, int count,
__pformat_t *stream )
* output quota is honoured.
*/
char buf[16];
- mbstate_t state;
- int len = wcrtomb(buf, L'\0', &state);
+ mbstate_t state = {0};
+ int len;
if( (stream->precision >= 0) && (count > stream->precision) )
/*
--
2.50.1
LGTM, thanks - please apply.
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public