Module: wine Branch: master Commit: d505c2dce7ac01368ceed6b42f8ee6adb6fa5395 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d505c2dce7ac01368ceed6b42f...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Aug 28 00:07:52 2017 +0300
comctl32/monthcal: Make sure set focus date is valid before using it (Valgrind).
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/comctl32/monthcal.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 97e0c8c..b94345c 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -641,11 +641,16 @@ static inline void MONTHCAL_GetDayRectI(const MONTHCAL_INFO *infoPtr, RECT *r, * * NOTE: when calendar index is unknown pass -1 */ -static inline void MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, - RECT *r, INT calIdx) +static BOOL MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTEMTIME *date, RECT *r, INT calIdx) { INT col, row;
+ if (!MONTHCAL_ValidateDate(date)) + { + SetRectEmpty(r); + return FALSE; + } + if (calIdx == -1) { INT cmp = MONTHCAL_CompareMonths(date, &infoPtr->calendars[0].month); @@ -668,6 +673,8 @@ static inline void MONTHCAL_GetDayRect(const MONTHCAL_INFO *infoPtr, const SYSTE
MONTHCAL_GetDayPos(infoPtr, date, &col, &row, calIdx); MONTHCAL_GetDayRectI(infoPtr, r, col, row, calIdx); + + return TRUE; }
static LRESULT @@ -739,20 +746,19 @@ static BOOL MONTHCAL_SetDayFocus(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *st) if(MONTHCAL_IsDateEqual(&infoPtr->focusedSel, st)) return FALSE;
/* invalidate old focused day */ - MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1); - InvalidateRect(infoPtr->hwndSelf, &r, FALSE); + if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1)) + InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
infoPtr->focusedSel = *st; }
- MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1); + /* On set invalidates new day, on reset clears previous focused day. */ + if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->focusedSel, &r, -1)) + InvalidateRect(infoPtr->hwndSelf, &r, FALSE);
if(!st && MONTHCAL_ValidateDate(&infoPtr->focusedSel)) infoPtr->focusedSel = st_null;
- /* on set invalidates new day, on reset clears previous focused day */ - InvalidateRect(infoPtr->hwndSelf, &r, FALSE); - return TRUE; }
@@ -1746,17 +1752,11 @@ MONTHCAL_UpdateToday(MONTHCAL_INFO *infoPtr, const SYSTEMTIME *today) return FALSE;
/* Invalidate old and new today day rectangle, and today label. */ - if (MONTHCAL_ValidateDate(&infoPtr->todaysDate)) - { - MONTHCAL_GetDayRect(infoPtr, &infoPtr->todaysDate, &rect, -1); + if (MONTHCAL_GetDayRect(infoPtr, &infoPtr->todaysDate, &rect, -1)) InvalidateRect(infoPtr->hwndSelf, &rect, FALSE); - }
- if (MONTHCAL_ValidateDate(today)) - { - MONTHCAL_GetDayRect(infoPtr, today, &rect, -1); + if (MONTHCAL_GetDayRect(infoPtr, today, &rect, -1)) InvalidateRect(infoPtr->hwndSelf, &rect, FALSE); - }
infoPtr->todaysDate = *today;