imm32: Validate the window handle passed to ImmGetContext.
This commit is contained in:
parent
5d64254986
commit
21a477e161
|
@ -1360,9 +1360,15 @@ BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
|
|||
*/
|
||||
HIMC WINAPI ImmGetContext(HWND hWnd)
|
||||
{
|
||||
HIMC rc = NULL;
|
||||
HIMC rc;
|
||||
|
||||
TRACE("%p\n", hWnd);
|
||||
|
||||
if (!IsWindow(hWnd))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
||||
return NULL;
|
||||
}
|
||||
if (!IMM_GetThreadData()->defaultContext)
|
||||
IMM_GetThreadData()->defaultContext = ImmCreateContext();
|
||||
|
||||
|
|
|
@ -557,6 +557,22 @@ static void test_ImmIsUIMessage(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_ImmGetContext(void)
|
||||
{
|
||||
HIMC himc;
|
||||
DWORD err;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
himc = ImmGetContext((HWND)0xffffffff);
|
||||
err = GetLastError();
|
||||
ok(himc == NULL, "ImmGetContext succeeded\n");
|
||||
ok(err == ERROR_INVALID_WINDOW_HANDLE, "got %u\n", err);
|
||||
|
||||
himc = ImmGetContext(hwnd);
|
||||
ok(himc != NULL, "ImmGetContext failed\n");
|
||||
ok(ImmReleaseContext(hwnd, himc), "ImmReleaseContext failed\n");
|
||||
}
|
||||
|
||||
START_TEST(imm32) {
|
||||
if (init())
|
||||
{
|
||||
|
@ -567,6 +583,7 @@ START_TEST(imm32) {
|
|||
test_ImmAssociateContextEx();
|
||||
test_ImmThreads();
|
||||
test_ImmIsUIMessage();
|
||||
test_ImmGetContext();
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue