From 4106697774ff533b2eeb223f87103fa464fc598a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 7 Nov 2023 16:24:08 -0800 Subject: [PATCH] Make sure we include the null terminator in XLookupStringAsUTF8() Fixes https://github.com/libsdl-org/SDL/issues/6728 --- src/video/x11/SDL_x11events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 9c7afcf445..2c8ed6b590 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -779,7 +779,7 @@ static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int { int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out); if (IsHighLatin1(buffer_return, result)) { - char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result); + char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result + 1); if (utf8_text) { SDL_strlcpy(buffer_return, utf8_text, bytes_buffer); SDL_free(utf8_text);