Nikolay Sivov : comctl32/monthcal: Fix memory leak on MCN_GETDAYSTATE notification.

Alexandre Julliard julliard at winehq.org
Mon Sep 28 11:54:38 CDT 2009


Module: wine
Branch: master
Commit: e3a7c6c7e7a18afaa9e47c3ddb9115a41e2fda51
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e3a7c6c7e7a18afaa9e47c3ddb9115a41e2fda51

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Sat Sep 26 15:55:27 2009 +0400

comctl32/monthcal: Fix memory leak on MCN_GETDAYSTATE notification.

---

 dlls/comctl32/monthcal.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index 9cee5fc..da45828 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -1233,7 +1233,7 @@ static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr)
 
   if(infoPtr->dwStyle & MCS_DAYSTATE) {
     NMDAYSTATE nmds;
-    int i;
+    INT i;
 
     nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
     nmds.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
@@ -1242,13 +1242,15 @@ static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr)
     nmds.prgDayState	= Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
 
     nmds.stStart = infoPtr->todaysDate;
-    nmds.stStart.wYear = infoPtr->curSel.wYear;
+    nmds.stStart.wYear  = infoPtr->curSel.wYear;
     nmds.stStart.wMonth = infoPtr->curSel.wMonth;
     nmds.stStart.wDay = 1;
 
     SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmds.nmhdr.idFrom, (LPARAM)&nmds);
-    for(i=0; i<infoPtr->monthRange; i++)
+    for(i = 0; i < infoPtr->monthRange; i++)
       infoPtr->monthdayState[i] = nmds.prgDayState[i];
+
+    Free(nmds.prgDayState);
   }
 }
 
@@ -1265,23 +1267,24 @@ static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr)
 
   if(infoPtr->dwStyle & MCS_DAYSTATE) {
     NMDAYSTATE nmds;
-    int i;
+    INT i;
 
     nmds.nmhdr.hwndFrom = infoPtr->hwndSelf;
     nmds.nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
     nmds.nmhdr.code     = MCN_GETDAYSTATE;
     nmds.cDayState	= infoPtr->monthRange;
-    nmds.prgDayState	= Alloc
-                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
+    nmds.prgDayState	= Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
 
     nmds.stStart = infoPtr->todaysDate;
-    nmds.stStart.wYear = infoPtr->curSel.wYear;
+    nmds.stStart.wYear  = infoPtr->curSel.wYear;
     nmds.stStart.wMonth = infoPtr->curSel.wMonth;
     nmds.stStart.wDay = 1;
 
     SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmds.nmhdr.idFrom, (LPARAM)&nmds);
-    for(i=0; i<infoPtr->monthRange; i++)
+    for(i = 0; i < infoPtr->monthRange; i++)
        infoPtr->monthdayState[i] = nmds.prgDayState[i];
+
+    Free(nmds.prgDayState);
   }
 }
 




More information about the wine-cvs mailing list