[PATCH 2/2] user32: Fix behavior of GetWindowInfo(0, NULL).

Brendan Shanks bshanks at codeweavers.com
Fri Sep 20 16:00:03 CDT 2019


Windows doesn't do a NULL check on the WINDOWINFO pointer.

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
---
 dlls/user32/tests/win.c | 2 +-
 dlls/user32/win.c       | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index be170f3cc1..28a3984deb 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -1006,7 +1006,7 @@ static void test_window_info(const char *hook, HWND hwnd)
 
     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());
 
     SetLastError(0xdeadbeef);
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 3582262b7d..11c3cc2362 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -3845,9 +3845,12 @@ UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPWSTR module, UINT size )
  */
 BOOL WINAPI DECLSPEC_HOTPATCH GetWindowInfo( HWND hwnd, PWINDOWINFO pwi)
 {
+    RECT rcWindow, rcClient;
+    if (!WIN_GetRectangles( hwnd, COORDS_SCREEN, &rcWindow, &rcClient )) return FALSE;
     if (!pwi) return FALSE;
-    if (!WIN_GetRectangles( hwnd, COORDS_SCREEN, &pwi->rcWindow, &pwi->rcClient )) return FALSE;
 
+    CopyRect(&pwi->rcWindow, &rcWindow);
+    CopyRect(&pwi->rcClient, &rcClient);
     pwi->dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
     pwi->dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
     pwi->dwWindowStatus = ((GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0);
-- 
2.17.1




More information about the wine-devel mailing list