Nikolay Sivov : user32: Handle NULL argument in GetKeyboardLayoutNameW().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jan 13 15:01:25 CST 2015


Module: wine
Branch: master
Commit: 151694a0bce3160387f6d8c54ebaa2b726dbd4c4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=151694a0bce3160387f6d8c54ebaa2b726dbd4c4

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Jan 12 01:24:20 2015 +0300

user32: Handle NULL argument in GetKeyboardLayoutNameW().

---

 dlls/user32/input.c       | 5 +++++
 dlls/user32/tests/input.c | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index ec81e60..1f05f34 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -966,6 +966,11 @@ BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
  */
 BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
 {
+    if (!pwszKLID)
+    {
+        SetLastError(ERROR_NOACCESS);
+        return FALSE;
+    }
     return USER_Driver->pGetKeyboardLayoutName(pwszKLID);
 }
 
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 39afeb7..76d0821 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -1595,6 +1595,14 @@ static void test_keyboard_layout_name(void)
     BOOL ret;
     char klid[KL_NAMELENGTH];
 
+if (0) /* crashes on native system */
+    ret = GetKeyboardLayoutNameA(NULL);
+
+    SetLastError(0xdeadbeef);
+    ret = GetKeyboardLayoutNameW(NULL);
+    ok(!ret, "got %d\n", ret);
+    ok(GetLastError() == ERROR_NOACCESS, "got %d\n", GetLastError());
+
     if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409) return;
 
     klid[0] = 0;




More information about the wine-cvs mailing list