mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
comctl32/monthcal: Fix parameter validation in MCM_SETCURSEL handler.
This commit is contained in:
parent
42733f980b
commit
2d2edc9a83
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user