Rob Shearman : comctl32: Fix possible use of uninitialised variable in REBAR_Paint.

Alexandre Julliard julliard at winehq.org
Mon Feb 25 06:51:43 CST 2008


Module: wine
Branch: master
Commit: f3c40f925d39517a7068ce0c3d5231310f5f53d5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f3c40f925d39517a7068ce0c3d5231310f5f53d5

Author: Rob Shearman <rob at codeweavers.com>
Date:   Mon Feb 25 08:59:51 2008 +0000

comctl32: Fix possible use of uninitialised variable in REBAR_Paint.

In the case where an hdc is passed in via the wParam, ps.fErase could be 
uninitialised. Fix this by rearranging the code so that ps is only used 
when an hdc isn't passed in.

---

 dlls/comctl32/rebar.c |   29 ++++++++++++++---------------
 1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c
index 92c1922..0784e61 100644
--- a/dlls/comctl32/rebar.c
+++ b/dlls/comctl32/rebar.c
@@ -3197,24 +3197,23 @@ REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 static LRESULT
 REBAR_Paint (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-    HDC hdc;
-    PAINTSTRUCT ps;
-    RECT rc;
-
-    GetClientRect(infoPtr->hwndSelf, &rc);
-    hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
-
-    TRACE("painting (%s) client (%s)\n",
-          wine_dbgstr_rect(&ps.rcPaint), wine_dbgstr_rect(&rc));
+    HDC hdc = (HDC)wParam;
 
-    if (ps.fErase) {
-	/* Erase area of paint if requested */
-        REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
+    if (hdc) {
+        TRACE("painting\n");
+        REBAR_Refresh (infoPtr, hdc);
+    } else {
+        PAINTSTRUCT ps;
+        hdc = BeginPaint (infoPtr->hwndSelf, &ps);
+        TRACE("painting (%s)\n", wine_dbgstr_rect(&ps.rcPaint));
+        if (ps.fErase) {
+            /* Erase area of paint if requested */
+            REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
+        }
+        REBAR_Refresh (infoPtr, hdc);
+	EndPaint (infoPtr->hwndSelf, &ps);
     }
 
-    REBAR_Refresh (infoPtr, hdc);
-    if (!wParam)
-	EndPaint (infoPtr->hwndSelf, &ps);
     return 0;
 }
 




More information about the wine-cvs mailing list