[PATCH v2 3/3] user32: Check that returned HBRUSH really is a brush object.
Jeff Smith
whydoubt at gmail.com
Tue Oct 20 10:35:15 CDT 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=14113
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
dlls/user32/button.c | 2 +-
dlls/user32/static.c | 3 ++-
dlls/user32/tests/static.c | 3 ---
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 4ff33624a43..d6b4d6e5943 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -188,7 +188,7 @@ static HBRUSH BUTTON_BrushSendMessage( HWND hwnd, HDC hDC, UINT message )
hBrush = (HBRUSH)SendMessageW( parent, message, (WPARAM)hDC, (LPARAM)hwnd );
/* Did the app forget to call DefWindowProc ? */
- if (!hBrush)
+ if (!hBrush || GetObjectType(hBrush) != OBJ_BRUSH)
hBrush = (HBRUSH)DefWindowProcW( parent, message, (WPARAM)hDC, (LPARAM)hwnd );
return hBrush;
}
diff --git a/dlls/user32/static.c b/dlls/user32/static.c
index 72e49e15e8f..f3f3c13fe69 100644
--- a/dlls/user32/static.c
+++ b/dlls/user32/static.c
@@ -293,7 +293,8 @@ static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
if (!parent) parent = hwnd;
hBrush = (HBRUSH) SendMessageW( parent,
WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
- if (!hBrush) /* did the app forget to call DefWindowProc ? */
+ /* Did the app forget to call DefWindowProc ? */
+ if (!hBrush || GetObjectType(hBrush) != OBJ_BRUSH)
{
/* FIXME: DefWindowProc should return different colors if a
manifest is present */
diff --git a/dlls/user32/tests/static.c b/dlls/user32/tests/static.c
index d42fc757c5d..c3a5486c308 100644
--- a/dlls/user32/tests/static.c
+++ b/dlls/user32/tests/static.c
@@ -322,11 +322,8 @@ static void test_style_colors(const char *class, int style, POINT *inside, POINT
(color_tests[i].brushcolor == CLR_INVALID || is_pushbutton) ? ocolor0 :
(is_simple || is_groupbox) ? ocolor0 :
color_tests[i].brushcolor;
- todo_wine_if(color_tests[i].brush != NULL && color_tests[i].brushcolor == CLR_INVALID && !is_pushbutton)
ok(icolor == icolor_exp, "(%s,%#x,%d) Expected color %#x inside text area, got %#x\n",
class, style, i, icolor_exp, icolor);
- todo_wine_if(color_tests[i].brush != NULL && color_tests[i].brushcolor == CLR_INVALID && !is_pushbutton &&
- !is_simple && !is_groupbox)
ok(ocolor == ocolor_exp, "(%s,%#x,%d) Expected color %#x outside text area, got %#x\n",
class, style, i, ocolor_exp, ocolor);
}
--
2.23.0
More information about the wine-devel
mailing list