Nikolay Sivov : comctl32/rebar: Fix index check condition for RB_SHOWBAND.

Alexandre Julliard julliard at winehq.org
Mon Jun 7 10:02:26 CDT 2010


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Jun  7 01:15:43 2010 +0400

comctl32/rebar: Fix index check condition for RB_SHOWBAND.

---

 dlls/comctl32/rebar.c       |    2 +-
 dlls/comctl32/tests/rebar.c |   31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c
index cd3abad..7a2995c 100644
--- a/dlls/comctl32/rebar.c
+++ b/dlls/comctl32/rebar.c
@@ -2779,7 +2779,7 @@ REBAR_ShowBand (REBAR_INFO *infoPtr, INT iBand, BOOL show)
 {
     REBAR_BAND *lpBand;
 
-    if (iBand < 0 || iBand > infoPtr->uNumBands)
+    if (iBand < 0 || iBand >= infoPtr->uNumBands)
 	return FALSE;
 
     lpBand = REBAR_GetBand(infoPtr, iBand);
diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c
index a75a064..d5f27b9 100644
--- a/dlls/comctl32/tests/rebar.c
+++ b/dlls/comctl32/tests/rebar.c
@@ -925,6 +925,36 @@ static HWND create_parent_window(void)
     return hwnd;
 }
 
+static void test_showband(void)
+{
+    HWND hRebar;
+    REBARBANDINFOA rbi;
+    BOOL ret;
+
+    hRebar = create_rebar_control();
+
+    /* no bands */
+    ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
+    ok(ret == FALSE, "got %d\n", ret);
+
+    rbi.cbSize = REBARBANDINFOA_V6_SIZE;
+    rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
+    rbi.cx = 200;
+    rbi.cxMinChild = 100;
+    rbi.cyMinChild = 30;
+    rbi.hwndChild = NULL;
+    SendMessageA(hRebar, RB_INSERTBAND, -1, (LPARAM)&rbi);
+
+    /* index out of range */
+    ret = SendMessageA(hRebar, RB_SHOWBAND, 1, TRUE);
+    ok(ret == FALSE, "got %d\n", ret);
+
+    ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
+    ok(ret == TRUE, "got %d\n", ret);
+
+    DestroyWindow(hRebar);
+}
+
 START_TEST(rebar)
 {
     HMODULE hComctl32;
@@ -948,6 +978,7 @@ START_TEST(rebar)
 
     test_bandinfo();
     test_colors();
+    test_showband();
 
     if(!is_font_installed("System") || !is_font_installed("Tahoma"))
     {




More information about the wine-cvs mailing list