From a878f0a02ad553b94b78b907715c691507dea501 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 21 Mar 2017 13:03:55 +0100 Subject: [PATCH] user32: Don't call IsChild with NULL window in EnableWindow. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/user32/tests/win.c | 2 ++ dlls/user32/win.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 6e11ff21d94..915012c2243 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -3091,7 +3091,9 @@ static void test_SetFocus(HWND hwnd) ShowWindow(child, SW_SHOW); SetFocus(child); ok( GetFocus() == child, "Focus should be on child %p\n", child ); + SetLastError(0xdeadbeef); EnableWindow(hwnd, FALSE); + ok(GetLastError() == 0xdeadbeef, "got error %u in EnableWindow call\n", GetLastError()); ok( GetFocus() == child, "Focus should still be on child %p\n", child ); EnableWindow(hwnd, TRUE); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 440657719e7..f3b4ef547c6 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2171,7 +2171,7 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) SetFocus( 0 ); /* A disabled window can't have the focus */ capture_wnd = GetCapture(); - if (hwnd == capture_wnd || IsChild(hwnd, capture_wnd)) + if (capture_wnd && (hwnd == capture_wnd || IsChild(hwnd, capture_wnd))) ReleaseCapture(); /* A disabled window can't capture the mouse */ SendMessageW( hwnd, WM_ENABLE, FALSE, 0 );