From c8dbb0c4c1ec4cc7979715a6ebc02ece90ae220e Mon Sep 17 00:00:00 2001 From: Brendan Shanks Date: Mon, 23 Sep 2019 10:41:07 -0700 Subject: [PATCH] user32: Fix behavior of GetWindowInfo(0, NULL). Windows doesn't do a NULL check on the WINDOWINFO pointer. Signed-off-by: Brendan Shanks Signed-off-by: Alexandre Julliard --- dlls/user32/tests/win.c | 2 +- dlls/user32/win.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 6b600cb1bc8..784849b2ba8 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -1007,7 +1007,7 @@ static void test_window_info(const char *hook, HWND hwnd) if (0) { /* crashes on XP, 2003 */ SetLastError(0xdeadbeef); ok(!pGetWindowInfo(0, NULL), "GetWindowInfo should fail\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError()); } diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 3582262b7de..3323ed3e41b 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -3845,9 +3845,13 @@ UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPWSTR module, UINT size ) */ BOOL WINAPI DECLSPEC_HOTPATCH GetWindowInfo( HWND hwnd, PWINDOWINFO pwi) { - if (!pwi) return FALSE; - if (!WIN_GetRectangles( hwnd, COORDS_SCREEN, &pwi->rcWindow, &pwi->rcClient )) return FALSE; + RECT rcWindow, rcClient; + if (!WIN_GetRectangles( hwnd, COORDS_SCREEN, &rcWindow, &rcClient )) return FALSE; + if (!pwi) return FALSE; + + pwi->rcWindow = rcWindow; + pwi->rcClient = rcClient; pwi->dwStyle = GetWindowLongW(hwnd, GWL_STYLE); pwi->dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE); pwi->dwWindowStatus = ((GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0);