From: Nikolay Sivov Subject: user32: Handle NULL argument in GetKeyboardLayoutNameW() Message-Id: <54B2F8B8.2000103@codeweavers.com> Date: Mon, 12 Jan 2015 01:27:04 +0300 https://bugs.winehq.org/show_bug.cgi?id=37882 From 2ee95e039c4b4524d86ed3ba2937fcf0a3166035 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 12 Jan 2015 01:24:20 +0300 Subject: [PATCH] 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; -- 2.1.4