From 169da05c534012137f355024debc02826c814671 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 14 Apr 2022 18:30:58 +0900 Subject: [PATCH] Fix too long buffer for ImmGetCompositionStringW() It return's byte size, not string length. So that multiplying by sizeof(WCHAR) isn't needed. --- src/win32_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index c3bd4db3..8c23279c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -858,7 +858,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { // get preedit data int length = preeditTextLength / sizeof(WCHAR); - LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, sizeof(WCHAR)); + LPWSTR buffer = (LPWSTR) _glfw_calloc(preeditTextLength, 1); LPSTR attributes = (LPSTR) _glfw_calloc(attrLength, 1); DWORD *clauses = (DWORD*) _glfw_calloc(clauseLength, 1); ImmGetCompositionStringW(hIMC, GCS_COMPSTR, buffer, preeditTextLength);