comctl32/rebar: Fix invalid band index access.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47991
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-11-21 10:45:20 +03:00 committed by Alexandre Julliard
parent 63f8231570
commit d6c0f9f22a
2 changed files with 24 additions and 3 deletions

View File

@ -1298,8 +1298,8 @@ static int REBAR_SetBandsHeight(const REBAR_INFO *infoPtr, INT iBeginBand, INT i
REBAR_BAND *lpBand;
int yMaxHeight = 0;
int yPos = yStart;
int row = REBAR_GetBand(infoPtr, iBeginBand)->iRow;
int i;
int row, i;
for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
{
lpBand = REBAR_GetBand(infoPtr, i);
@ -1308,6 +1308,8 @@ static int REBAR_SetBandsHeight(const REBAR_INFO *infoPtr, INT iBeginBand, INT i
}
TRACE("Bands [%d; %d) height: %d\n", iBeginBand, iEndBand, yMaxHeight);
row = iBeginBand < iEndBand ? REBAR_GetBand(infoPtr, iBeginBand)->iRow : 0;
for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
{
lpBand = REBAR_GetBand(infoPtr, i);

View File

@ -499,6 +499,7 @@ static void test_layout(void)
REBARBANDINFOA rbi;
HIMAGELIST himl;
REBARINFO ri;
int count;
rbsize_results_init();
@ -660,9 +661,27 @@ static void test_layout(void)
SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
check_sizes();
rbsize_results_free();
DestroyWindow(hRebar);
pImageList_Destroy(himl);
/* One hidden band. */
hRebar = create_rebar_control();
rbi.cbSize = REBARBANDINFOA_V6_SIZE;
rbi.fMask = RBBIM_STYLE | RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
rbi.fStyle = RBBS_HIDDEN;
rbi.cx = 200;
rbi.cxMinChild = 100;
rbi.cyMinChild = 30;
rbi.hwndChild = NULL;
SendMessageA(hRebar, RB_INSERTBANDA, -1, (LPARAM)&rbi);
count = SendMessageA(hRebar, RB_GETROWCOUNT, 0, 0);
ok(!count, "Unexpected row count %d.\n", count);
DestroyWindow(hRebar);
rbsize_results_free();
}
#if 0 /* use this to generate more tests */