SMATCH: unfreed mem in dlls/commdlg/colordlg.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

found by the unfree-wine.pl smatch script.

License: LGPL, X11
Changelog:
	Michael Stefaniuc <mstefani@redhat.com>
	- fix mem leaks on error path

bye
	michael
-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
System Administration           Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani@redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
? dlls/commdlg/cdlg_Ro.rc
Index: dlls/commdlg/colordlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/colordlg.c,v
retrieving revision 1.44
diff -u -r1.44 colordlg.c
--- dlls/commdlg/colordlg.c	17 Sep 2003 04:28:28 -0000	1.44
+++ dlls/commdlg/colordlg.c	27 Sep 2003 22:35:54 -0000
@@ -816,14 +816,15 @@
    {
        CHOOSECOLORW *ch32;
        CHOOSECOLOR16 *ch16 = (CHOOSECOLOR16 *) lParam;
-       ch32 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW) );
-       lpp->lpcc = ch32;
-       lpp->lpcc16 = ch16;
-       if (lpp->lpcc16->lStructSize != sizeof(CHOOSECOLOR16) )
+       if (ch16->lStructSize != sizeof(CHOOSECOLOR16) )
        {
+           HeapFree(GetProcessHeap(), 0, lpp);
            EndDialog (hDlg, 0) ;
            return FALSE;
        }
+       ch32 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW) );
+       lpp->lpcc = ch32;
+       lpp->lpcc16 = ch16;
        ch32->lStructSize = sizeof(CHOOSECOLORW);
        ch32->hwndOwner = HWND_32(ch16->hwndOwner);
        /* Should be an HINSTANCE but MS made a typo */
@@ -833,12 +834,14 @@
        ch32->Flags = ch16->Flags;
    }
    else
-       lpp->lpcc = (LPCHOOSECOLORW) lParam;
-
-   if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLORW) )
    {
-      EndDialog (hDlg, 0) ;
-      return FALSE;
+       lpp->lpcc = (LPCHOOSECOLORW) lParam;
+       if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLORW) )
+       {
+           HeapFree(GetProcessHeap(), 0, lpp);
+           EndDialog (hDlg, 0) ;
+           return FALSE;
+       }
    }
    SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
 

Attachment: pgp00189.pgp
Description: PGP signature


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux