[1/2] user32: Don't crash for unknown button styles (try 2)

André Hentschel nerv at dawncrow.de
Mon Aug 9 09:45:00 CDT 2010


got that case with a MFC application which had a 3state checkbox with buttonstyle 15(0x0F)
with this fix everything is fine as the painting of the button is handled elsewhere, without that fix it crashes as it reads bad data behind the array.
i also bet that the strange style is totally handled by the third-party app as it only needs "winetricks vcrun6" and can "simulate" msoffice 2007 dialog style.

---
 dlls/user32/button.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index 54d54dc..ce482c6 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -197,7 +197,7 @@ static inline UINT get_button_type( LONG window_style )
 /* paint a button of any type */
 static inline void paint_button( HWND hwnd, LONG style, UINT action )
 {
-    if (btnPaintFunc[style] && IsWindowVisible(hwnd))
+    if (style < MAX_BTN_TYPE && btnPaintFunc[style] && IsWindowVisible(hwnd))
     {
         HDC hdc = GetDC( hwnd );
         btnPaintFunc[style]( hwnd, hdc, action );
@@ -298,7 +298,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
 
     case WM_PRINTCLIENT:
     case WM_PAINT:
-        if (btnPaintFunc[btn_type])
+        if (btn_type < MAX_BTN_TYPE && btnPaintFunc[btn_type])
         {
             PAINTSTRUCT ps;
             HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list