[PATCH 6/6] Fix parameter validation in MCM_SETMAXSELCOUNT handler
Nikolay Sivov
bunglehead at gmail.com
Thu Oct 1 14:02:56 CDT 2009
---
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);
}
--
1.5.6.5
--=-tHHuJzR1W0LQcad2lDNp--
More information about the wine-patches
mailing list