comctl32/monthcal: Fix parameter validation in MCM_SETCURSEL handler.

This commit is contained in:
Nikolay Sivov 2009-10-05 23:05:53 +04:00 committed by Alexandre Julliard
parent 42733f980b
commit 2d2edc9a83
2 changed files with 22 additions and 5 deletions

View File

@ -252,11 +252,11 @@ static BOOL MONTHCAL_IsDateInValidRange(const MONTHCAL_INFO *infoPtr, const SYST
(MONTHCAL_CompareSystemTime(date, &min_allowed_date) == -1)) return FALSE;
if(infoPtr->rangeValid & GDTR_MAX) {
if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxSel) == 1)) return FALSE;
if((MONTHCAL_CompareSystemTime(date, &infoPtr->maxDate) == 1)) return FALSE;
}
if(infoPtr->rangeValid & GDTR_MIN) {
if((MONTHCAL_CompareSystemTime(date, &infoPtr->minSel) == -1)) return FALSE;
if((MONTHCAL_CompareSystemTime(date, &infoPtr->minDate) == -1)) return FALSE;
}
return TRUE;
@ -1255,14 +1255,14 @@ MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
if(infoPtr->dwStyle & MCS_MULTISELECT) return FALSE;
if(!MONTHCAL_ValidateDate(curSel)) return FALSE;
/* exit earlier if selection equals current */
if (MONTHCAL_IsDateEqual(&infoPtr->curSel, curSel)) return TRUE;
if(!MONTHCAL_IsDateInValidRange(infoPtr, curSel)) return FALSE;
infoPtr->minSel = *curSel;
infoPtr->maxSel = *curSel;
/* exit earlier if selection equals current */
if (MONTHCAL_IsDateEqual(&infoPtr->curSel, curSel)) return TRUE;
infoPtr->curSel = *curSel;
/* FIXME: it's possible to reduce rectangle here */

View File

@ -822,6 +822,23 @@ static void test_monthcal_currdate(void)
expect(st_original.wMinute, st_test.wMinute);
expect(st_original.wSecond, st_test.wSecond);
/* setting selection equal to current reports success even if out range */
memset(&st_new, 0, sizeof(st_new));
st_new.wYear = 2009;
st_new.wDay = 5;
st_new.wMonth = 10;
res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new);
expect(1, res);
memset(&st_test, 0, sizeof(st_test));
st_test.wYear = 2009;
st_test.wDay = 6;
st_test.wMonth = 10;
res = SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN, (LPARAM)&st_test);
expect(1, res);
/* set to current again */
res = SendMessage(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new);
expect(1, res);
DestroyWindow(hwnd);
}