Nikolay Sivov : comctl32/monthcal: Fix parameter validation in MCM_SETMAXSELCOUNT handler.
Alexandre Julliard
julliard at winehq.org
Fri Oct 2 11:02:20 CDT 2009
Module: wine
Branch: master
Commit: 5d530fee54d8c976432eb8328e02be62d6bfa226
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5d530fee54d8c976432eb8328e02be62d6bfa226
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Thu Oct 1 23:02:56 2009 +0400
comctl32/monthcal: Fix parameter validation in MCM_SETMAXSELCOUNT handler.
---
dlls/comctl32/monthcal.c | 7 ++++---
dlls/comctl32/tests/monthcal.c | 15 +++++++++++++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index 384efe7..ed059ff 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -1087,9 +1087,10 @@ MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, INT max)
{
TRACE("%d\n", max);
- if(infoPtr->dwStyle & MCS_MULTISELECT) {
- infoPtr->maxSelCount = max;
- }
+ if(!(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE;
+ if(max <= 0) return FALSE;
+
+ infoPtr->maxSelCount = max;
return TRUE;
}
diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c
index cd9d15e..e0479cd 100644
--- a/dlls/comctl32/tests/monthcal.c
+++ b/dlls/comctl32/tests/monthcal.c
@@ -1316,6 +1316,10 @@ static void test_monthcal_maxselday(void)
/* if no style specified default to 1 */
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(1, res);
+ res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 5, 0);
+ expect(0, res);
+ res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
+ expect(1, res);
/* try to set style */
style = GetWindowLong(hwnd, GWL_STYLE);
@@ -1351,13 +1355,20 @@ static void test_monthcal_maxselday(void)
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(15, res);
+ /* test invalid value */
res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, -1, 0);
- todo_wine {expect(0, res);}
+ expect(0, res);
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
- todo_wine {expect(15, res);}
+ expect(15, res);
ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_max_sel_day_seq, "monthcal MaxSelDay", FALSE);
+ /* zero value is invalid too */
+ res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 0, 0);
+ expect(0, res);
+ res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
+ expect(15, res);
+
DestroyWindow(hwnd);
}
More information about the wine-cvs
mailing list