https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f7a4c26322d789e9f40bed61484376b6cef930c5

commit f7a4c26322d789e9f40bed61484376b6cef930c5
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Mon Nov 27 20:25:58 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Mon Nov 27 20:25:58 2023 +0900

    [INPUT] Fix exception on SPI_SETDEFALTINPUTLANG (#6043)
    
    Follow-up to #4666. Fix an abnormal termination at setting the default 
language.
    - pCurrent was NULL at the scene. Don't use it there for 
SPI_SETDEFALTINPUTLANG.
    - Save the default keyboard layout. Use it.
    CORE-11700, CORE-13244, CORE-18364
---
 dll/cpl/input/input_list.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dll/cpl/input/input_list.c b/dll/cpl/input/input_list.c
index 8cb6b443cca..e7026fe8853 100644
--- a/dll/cpl/input/input_list.c
+++ b/dll/cpl/input/input_list.c
@@ -385,6 +385,7 @@ InputList_Process(VOID)
     DWORD dwNumber;
     BOOL bRet = FALSE;
     HKEY hPreloadKey, hSubstKey;
+    HKL hDefaultKL = NULL;
 
     if (!InputList_PrepareUserRegistry(&hPreloadKey, &hSubstKey))
     {
@@ -442,6 +443,9 @@ InputList_Process(VOID)
 
             /* Activate the DEFAULT entry */
             ActivateKeyboardLayout(pCurrent->hkl, KLF_RESET);
+
+            /* Save it */
+            hDefaultKL = pCurrent->hkl;
             break;
         }
     }
@@ -467,7 +471,7 @@ InputList_Process(VOID)
     }
 
     /* Change the default keyboard language */
-    if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &pCurrent->hkl, 0))
+    if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &hDefaultKL, 0))
     {
         DWORD dwRecipients = BSM_ALLDESKTOPS | BSM_APPLICATIONS;
 
@@ -475,7 +479,7 @@ InputList_Process(VOID)
                                 &dwRecipients,
                                 WM_INPUTLANGCHANGEREQUEST,
                                 INPUTLANGCHANGE_SYSCHARSET,
-                                (LPARAM)pCurrent->hkl);
+                                (LPARAM)hDefaultKL);
     }
 
     /* Retry to delete (in case of failure to delete the default keyboard) */

Reply via email to