[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    mciwave: Fix a leak when Open fails (valgrind).
From:       <Joerg-Cyril.Hoehle () t-systems ! com>
Date:       2011-02-28 10:25:05
Message-ID: 97D47811BFBA4B48A7089A20E4C7AF02087F147251 () HE110881 ! EMEA1 ! CDS ! T-INTERNAL ! COM
[Download RAW message or body]

Hi,

one hunk is the leak, the others are removal of superfluous casts around th=
at pointer.
This fixes another leak found in the logs of #26050.

Regards,
 J=F6rg H=F6hle=

["0001-mciwave-Fix-a-leak-when-Open-fails-valgrind.patch" (application/octet-stream)]

From c3866a594b4dca92df370f9214d2186e64f40c1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jörg Höhle?= <hoehle@users.sourceforge.net>
Date: Fri, 25 Feb 2011 15:58:47 +0100
Subject: mciwave: Fix a leak when Open fails (valgrind).

---
 dlls/mciwave/mciwave.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/mciwave/mciwave.c b/dlls/mciwave/mciwave.c
index 1cf3556..9a62f8f 100644
--- a/dlls/mciwave/mciwave.c
+++ b/dlls/mciwave/mciwave.c
@@ -465,7 +465,7 @@ static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename)
     fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR));
     if (!fn) return MCIERR_OUT_OF_MEMORY;
     strcpyW(fn, filename);
-    HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
+    HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
     wmw->lpFileName = fn;

     if (strlenW(filename) > 0) {
@@ -568,6 +568,8 @@ static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_P
 	if (wmw->hFile != 0)
 	    mmioClose(wmw->hFile, 0);
 	wmw->hFile = 0;
+	HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
+	wmw->lpFileName = NULL;
     }
     return dwRet;
 }
@@ -680,7 +682,7 @@ static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARM
     if (wmw->lpWaveFormat != &wmw->wfxRef)
 	HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat);
     wmw->lpWaveFormat = &wmw->wfxRef;
-    HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
+    HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
     wmw->lpFileName = NULL;

     if ((dwFlags & MCI_NOTIFY) && lpParms) {
@@ -1025,7 +1027,7 @@ static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt
      * we don't modify the wave part of an existing file (ie. we always erase an
      * existing content, we don't overwrite)
      */
-    HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
+    HeapFree(GetProcessHeap(), 0, wmw->lpFileName);
     dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName);
     if (dwRet != 0) return dwRet;

--
1.7.0.4





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic