From d7f0a47e37145773163732c5ca635feb18b50f88 Mon Sep 17 00:00:00 2001 From: dolphin6k Date: Sun, 17 Oct 2021 21:08:39 +0900 Subject: [PATCH] Missing format specifier and wrong maximum length for swprintf(). --- src/tuxpaint.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 95765866d..982193acc 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -343,16 +343,17 @@ static void mtw(wchar_t * wtok, char *tok, size_t size) ui16 = malloc(size); char *wrptr = (char *)ui16; - size_t in, out; + size_t in, out, n; iconv_t trans; in = size; out = size; + n = size / sizeof(wchar_t); trans = iconv_open("WCHAR_T", "UTF-8"); - iconv(trans, (const char **)&tok, &in, &wrptr, &out); + iconv(trans, (char **)&tok, &in, &wrptr, &out); *((wchar_t *) wrptr) = L'\0'; - swprintf(wtok, size, ui16); + swprintf(wtok, n, L"%ls", ui16); free(ui16); iconv_close(trans); }