[PATCH 6/7] Fix parameter validation in MCM_SETCURSEL handler
Nikolay Sivov
bunglehead at gmail.com
Mon Oct 5 14:05:53 CDT 2009
---
dlls/comctl32/monthcal.c | 10 +++++-----
dlls/comctl32/tests/monthcal.c | 17 +++++++++++++++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index 83c3415..83a2c8a 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -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 */
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c
index 3b38e82..8234126 100644
--- a/dlls/comctl32/tests/monthcal.c
+++ b/dlls/comctl32/tests/monthcal.c
@@ -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);
}
--
1.5.6.5
--=-SPLojZoFCdYiJNkFobE2--
More information about the wine-patches
mailing list