Henri Verbeet : user32: Verify we got a valid window handle in GetDCEx().
Alexandre Julliard
julliard at winehq.org
Wed May 19 10:34:17 CDT 2010
Module: wine
Branch: master
Commit: 2c2e3f8665913776c84171c9521392d6f4c31fd3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2c2e3f8665913776c84171c9521392d6f4c31fd3
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Wed May 19 11:13:38 2010 +0200
user32: Verify we got a valid window handle in GetDCEx().
---
dlls/user32/painting.c | 2 ++
dlls/user32/tests/dce.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index 732c889..efb0884 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -908,6 +908,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
TRACE("hwnd %p, hrgnClip %p, flags %08x\n", hwnd, hrgnClip, flags);
+ if (!IsWindow(hwnd)) return 0;
+
/* fixup flags */
if (flags & (DCX_WINDOW | DCX_PARENTCLIP)) flags |= DCX_CACHE;
diff --git a/dlls/user32/tests/dce.c b/dlls/user32/tests/dce.c
index 37b9546..31c6ec0 100644
--- a/dlls/user32/tests/dce.c
+++ b/dlls/user32/tests/dce.c
@@ -392,6 +392,23 @@ static void test_invisible_create(void)
DestroyWindow(hwnd_owndc);
}
+static void test_destroyed_window(void)
+{
+ HDC dc;
+
+ dc = GetDCEx(hwnd_cache, 0, DCX_USESTYLE);
+ ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
+
+ dc = GetDCEx(hwnd_owndc, 0, DCX_USESTYLE);
+ ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
+
+ dc = GetDCEx(hwnd_classdc, 0, DCX_USESTYLE);
+ ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
+
+ dc = GetDCEx(hwnd_classdc2, 0, DCX_USESTYLE);
+ ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
+}
+
START_TEST(dce)
{
WNDCLASSA cls;
@@ -431,4 +448,11 @@ START_TEST(dce)
test_dc_visrgn();
test_begin_paint();
test_invisible_create();
+
+ DestroyWindow(hwnd_classdc2);
+ DestroyWindow(hwnd_classdc);
+ DestroyWindow(hwnd_owndc);
+ DestroyWindow(hwnd_cache);
+
+ test_destroyed_window();
}
More information about the wine-cvs
mailing list