comctl32/tab: Fix reading out of array bounds on TCM_SETCURSEL.

This commit is contained in:
Nikolay Sivov 2009-11-19 21:05:14 +03:00 committed by Alexandre Julliard
parent d28eabda5c
commit 3371ba9f73
1 changed files with 6 additions and 5 deletions

View File

@ -247,16 +247,17 @@ static inline LRESULT TAB_SetCurSel (TAB_INFO *infoPtr, INT iItem)
TRACE("(%p %d)\n", infoPtr, iItem);
if (iItem < 0)
infoPtr->iSelected=-1;
infoPtr->iSelected = -1;
else if (iItem >= infoPtr->uNumItem)
return -1;
else {
if (infoPtr->iSelected != iItem) {
TAB_GetItem(infoPtr, prevItem)->dwState &= ~TCIS_BUTTONPRESSED;
if (prevItem != iItem) {
if (prevItem != -1)
TAB_GetItem(infoPtr, prevItem)->dwState &= ~TCIS_BUTTONPRESSED;
TAB_GetItem(infoPtr, iItem)->dwState |= TCIS_BUTTONPRESSED;
infoPtr->iSelected=iItem;
infoPtr->uFocus=iItem;
infoPtr->iSelected = iItem;
infoPtr->uFocus = iItem;
TAB_EnsureSelectionVisible(infoPtr);
TAB_InvalidateTabArea(infoPtr);
}