Module: wine Branch: master Commit: d71fb7229f18028a31f1b6b437e576af14787e56 URL: https://gitlab.winehq.org/wine/wine/-/commit/d71fb7229f18028a31f1b6b437e576a...
Author: Paul Gofman pgofman@codeweavers.com Date: Fri Mar 8 19:45:07 2024 -0600
imm32: Set lengths to 0 for NULL strings in ImmSetCompositionString().
---
dlls/imm32/imm.c | 6 ++++++ dlls/imm32/tests/imm32.c | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 94de6c0f6d7..8c8504a092d 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -2539,6 +2539,9 @@ BOOL WINAPI ImmSetCompositionStringA( return FALSE;
if (!(ime = imc_select_ime( data ))) return FALSE; + if (!lpComp) dwCompLen = 0; + if (!lpRead) dwReadLen = 0; + if (!ime_is_unicode( ime )) return ime->pImeSetCompositionString( hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen );
comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0); @@ -2596,6 +2599,9 @@ BOOL WINAPI ImmSetCompositionStringW( return FALSE;
if (!(ime = imc_select_ime( data ))) return FALSE; + if (!lpComp) dwCompLen = 0; + if (!lpRead) dwReadLen = 0; + if (ime_is_unicode( ime )) return ime->pImeSetCompositionString( hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen );
comp_len = WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, NULL, 0, NULL, diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 7131bc2f6a5..db73463ef49 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -1085,12 +1085,24 @@ static void test_SCS_SETSTR(void) DWORD prop;
imc = ImmGetContext(hwnd); - ret = ImmSetCompositionStringW(imc, SCS_SETSTR, string, sizeof(string), NULL,0); + ret = ImmSetCompositionStringW(imc, SCS_SETSTR, string, sizeof(string), NULL, 0); if (!ret) { win_skip("Composition isn't supported\n"); ImmReleaseContext(hwnd, imc); return; } + + ret = ImmSetCompositionStringW(imc, SCS_SETSTR, NULL, 128, NULL, 128); + ok(ret, "got error %lu.\n", GetLastError()); + + alen = ImmGetCompositionStringA(imc, GCS_COMPSTR, cstring, 20); + ok(!alen, "got %ld.\n", alen); + wlen = ImmGetCompositionStringW(imc, GCS_COMPSTR, wstring, 20); + ok(!wlen, "got %ld.\n", alen); + + ret = ImmSetCompositionStringW(imc, SCS_SETSTR, string, sizeof(string), NULL, 2); + ok(ret, "got error %lu.\n", GetLastError()); + msg_spy_flush_msgs();
alen = ImmGetCompositionStringA(imc, GCS_COMPSTR, cstring, 20);