[WINMM] fix mci.c memory leak

Robert Reif reif at earthlink.net
Mon Mar 14 22:30:48 CST 2005


Fix memory leak in error path.

Found by smatch.
-------------- next part --------------
Index: dlls/winmm/mci.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/mci.c,v
retrieving revision 1.59
diff -p -u -r1.59 mci.c
--- dlls/winmm/mci.c	26 Feb 2005 17:41:11 -0000	1.59
+++ dlls/winmm/mci.c	15 Mar 2005 04:25:06 -0000
@@ -1455,10 +1455,13 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstr
     len = MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, NULL, 0 );
     lpwstrCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
     MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, lpwstrCommand, len );
-    if (lpstrRet)
-    {
+    if (lpstrRet) {
         lpwstrRet = HeapAlloc(GetProcessHeap(), 0, uRetLen * sizeof(WCHAR));
-        if (!lpwstrRet) return MCIERR_OUT_OF_MEMORY;
+        if (!lpwstrRet) {
+            WARN("no memory\n");
+            HeapFree( GetProcessHeap(), 0, lpwstrCommand );
+            return MCIERR_OUT_OF_MEMORY;
+        }
     }
     ret = mciSendStringW(lpwstrCommand, lpwstrRet, uRetLen, hwndCallback);
     if (lpwstrRet)


More information about the wine-patches mailing list