From 1603a51d4ee2454dc8bb479a128e702ee124c31f Mon Sep 17 00:00:00 2001 From: Damjan Jovanovic Date: Sat, 15 Nov 2008 18:15:04 +0200 Subject: [PATCH] user32: Handle NULL rectangles in WM_NCCALCSIZE. --- dlls/user32/nonclient.c | 3 +++ dlls/user32/tests/win.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/dlls/user32/nonclient.c b/dlls/user32/nonclient.c index 3fa870e63a1..708ed8095a8 100644 --- a/dlls/user32/nonclient.c +++ b/dlls/user32/nonclient.c @@ -417,6 +417,9 @@ LRESULT NC_HandleNCCalcSize( HWND hwnd, RECT *winRect ) LONG style = GetWindowLongW( hwnd, GWL_STYLE ); LONG exStyle = GetWindowLongW( hwnd, GWL_EXSTYLE ); + if (winRect == NULL) + return 0; + if (cls_style & CS_VREDRAW) result |= WVR_VREDRAW; if (cls_style & CS_HREDRAW) result |= WVR_HREDRAW; diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 827d0e31f30..f0e143a5f18 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -781,6 +781,7 @@ static void test_nonclient_area(HWND hwnd) RECT rc_window, rc_client, rc; BOOL menu; BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0; + LRESULT ret; style = GetWindowLongA(hwnd, GWL_STYLE); exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE); @@ -809,6 +810,10 @@ static void test_nonclient_area(HWND hwnd) trace("calc client: (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom); ok(EqualRect(&rc, &rc_client), "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style, exstyle, menu); + /* NULL rectangle shouldn't crash */ + ret = DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, 0); + ok(ret == 0, "NULL rectangle returned %ld instead of 0\n", ret); + /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */; if (is_win9x) return;