The parameter to _vsnwprintf is a number of wchar_t's, not a number
of bytes.

Reported-by: Julien Vary <julienv...@gmail.com>
---
 mingw-w64-crt/stdio/_vscwprintf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-crt/stdio/_vscwprintf.c 
b/mingw-w64-crt/stdio/_vscwprintf.c
index 635074b4e..eafd1f254 100644
--- a/mingw-w64-crt/stdio/_vscwprintf.c
+++ b/mingw-w64-crt/stdio/_vscwprintf.c
@@ -33,7 +33,7 @@ static int __cdecl emu__vscwprintf(const wchar_t * 
__restrict__ format, va_list
     }
 
     /* if the number of characters to write is greater than size, 
_vsnwprintf() returns -1 */
-    while (size < SIZE_MAX/2 && (ret = _vsnwprintf(buffer, size, format, 
arglist)) < 0) {
+    while (size < SIZE_MAX/2 && (ret = _vsnwprintf(buffer, size / 
sizeof(wchar_t), format, arglist)) < 0) {
         /* in this case try with larger buffer */
         size *= 2;
         new_buffer = realloc(buffer, size);
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to