From bd9e6081333240050584eb216b208728fbccf13b Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Tue, 1 Oct 2013 14:30:12 -0500 Subject: [PATCH] imm32: ImmGetCandidateWindow should not return unset data. --- dlls/imm32/imm.c | 7 +++++++ dlls/imm32/tests/imm32.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c index 93e71af4bdd..47381036555 100644 --- a/dlls/imm32/imm.c +++ b/dlls/imm32/imm.c @@ -636,6 +636,7 @@ HIMC WINAPI ImmCreateContext(void) InputContextData *new_context; LPGUIDELINE gl; LPCANDIDATEINFO ci; + int i; new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData)); @@ -663,6 +664,9 @@ HIMC WINAPI ImmCreateContext(void) gl->dwSize = sizeof(GUIDELINE); ImmUnlockIMCC(new_context->IMC.hGuideLine); + for (i = 0; i < sizeof(new_context->IMC.cfCandForm) / sizeof(CANDIDATEFORM); i++) + new_context->IMC.cfCandForm[i].dwIndex = ~0u; + /* Initialize the IME Private */ new_context->IMC.hPrivate = ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize); @@ -1035,6 +1039,9 @@ BOOL WINAPI ImmGetCandidateWindow( if ( dwIndex >= (sizeof(data->IMC.cfCandForm) / sizeof(CANDIDATEFORM)) ) return FALSE; + if (data->IMC.cfCandForm[dwIndex].dwIndex != dwIndex) + return FALSE; + *lpCandidate = data->IMC.cfCandForm[dwIndex]; return TRUE; diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c index 03243040b25..7b819657bd6 100644 --- a/dlls/imm32/tests/imm32.c +++ b/dlls/imm32/tests/imm32.c @@ -465,6 +465,7 @@ static void test_ImmThreads(void) BOOL rc; LOGFONT lf; COMPOSITIONFORM cf; + CANDIDATEFORM cdf; DWORD status, sentence; POINT pt; @@ -552,6 +553,23 @@ static void test_ImmThreads(void) rc = ImmGetStatusWindowPos(otherHimc, &pt); ok(rc != 0 || broken(rc == 0), "ImmGetStatusWindowPos failed\n"); + /* Candidate Window */ + rc = ImmGetCandidateWindow(himc, 0, &cdf); + ok (rc == 0, "ImmGetCandidateWindow should fail\n"); + cdf.dwIndex = 0; + cdf.dwStyle = CFS_CANDIDATEPOS; + cdf.ptCurrentPos.x = 0; + cdf.ptCurrentPos.y = 0; + rc = ImmSetCandidateWindow(himc, &cdf); + ok (rc == 1, "ImmSetCandidateWindow should succeed\n"); + rc = ImmGetCandidateWindow(himc, 0, &cdf); + ok (rc == 1, "ImmGetCandidateWindow should succeed\n"); + + rc = ImmGetCandidateWindow(otherHimc, 0, &cdf); + todo_wine ok (rc == 0, "ImmGetCandidateWindow should fail\n"); + rc = ImmSetCandidateWindow(otherHimc, &cdf); + todo_wine ok (rc == 0, "ImmSetCandidateWindow should fail\n"); + ImmReleaseContext(threadinfo.hwnd,otherHimc); ImmReleaseContext(hwnd,himc);