Piotr Caban : imm32: Exit on invalid window in ImmAssociateContext.

Alexandre Julliard julliard at winehq.org
Fri Oct 15 15:40:06 CDT 2021


Module: wine
Branch: master
Commit: 266c1101b3e0e0297b6062a4d34b2b766b4c9d33
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=266c1101b3e0e0297b6062a4d34b2b766b4c9d33

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Oct 15 15:26:57 2021 +0200

imm32: Exit on invalid window in ImmAssociateContext.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/imm32/imm.c | 45 +++++++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index d933ca06c2f..cbcc70daedf 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -583,12 +583,13 @@ BOOL WINAPI ImmSetActiveContext(HWND hwnd, HIMC himc, BOOL activate)
  */
 HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
 {
-    HIMC old = NULL;
     InputContextData *data = get_imc_data(hIMC);
+    HIMC defaultContext;
+    HIMC old;
 
     TRACE("(%p, %p):\n", hWnd, hIMC);
 
-    if(hIMC && !data)
+    if (!IsWindow(hWnd) || (hIMC && !data))
         return NULL;
 
     /*
@@ -600,30 +601,26 @@ HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
     if (hIMC && IMM_IsCrossThreadAccess(hWnd, hIMC))
         return NULL;
 
-    if (hWnd)
-    {
-        HIMC defaultContext = get_default_context( hWnd );
-        old = RemovePropW(hWnd,szwWineIMCProperty);
+    defaultContext = get_default_context( hWnd );
+    old = RemovePropW(hWnd, szwWineIMCProperty);
+    if (old == NULL)
+        old = defaultContext;
+    else if (old == (HIMC)-1)
+        old = NULL;
 
-        if (old == NULL)
-            old = defaultContext;
-        else if (old == (HIMC)-1)
-            old = NULL;
-
-        if (hIMC != defaultContext)
-        {
-            if (hIMC == NULL) /* Meaning disable imm for that window*/
-                SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1);
-            else
-                SetPropW(hWnd,szwWineIMCProperty,hIMC);
-        }
+    if (hIMC != defaultContext)
+    {
+        if (hIMC == NULL) /* Meaning disable imm for that window*/
+            SetPropW(hWnd, szwWineIMCProperty, (HANDLE)-1);
+        else
+            SetPropW(hWnd, szwWineIMCProperty, hIMC);
+    }
 
-        if (old)
-        {
-            InputContextData *old_data = old;
-            if (old_data->IMC.hWnd == hWnd)
-                old_data->IMC.hWnd = NULL;
-        }
+    if (old)
+    {
+        InputContextData *old_data = old;
+        if (old_data->IMC.hWnd == hWnd)
+            old_data->IMC.hWnd = NULL;
     }
 
     if (!hIMC)




More information about the wine-cvs mailing list