Jörg Höhle : winecoreaudio: Properly allocate the WAVEFORMATEXTENSIBLE returned by GetMixFormat.

Alexandre Julliard julliard at winehq.org
Mon Jun 6 15:19:10 CDT 2011


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

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Sun Jun  5 10:26:57 2011 +0200

winecoreaudio: Properly allocate the WAVEFORMATEXTENSIBLE returned by GetMixFormat.

---

 dlls/winecoreaudio.drv/mmdevdrv.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index 9075aa8..2819ca7 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -1155,13 +1155,12 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
 
     if(!pwfx)
         return E_POINTER;
+    *pwfx = NULL;
 
-    *pwfx = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEFORMATEXTENSIBLE));
-    if(!*pwfx)
+    fmt = CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE));
+    if(!fmt)
         return E_OUTOFMEMORY;
 
-    fmt = (WAVEFORMATEXTENSIBLE*)*pwfx;
-
     fmt->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
 
     addr.mScope = This->scope;
@@ -1170,21 +1169,21 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
 
     sc = AudioObjectGetPropertyDataSize(This->adevid, &addr, 0, NULL, &size);
     if(sc != noErr){
-        HeapFree(GetProcessHeap(), 0, fmt);
+        CoTaskMemFree(fmt);
         WARN("Unable to get size for _StreamConfiguration property: %lx\n", sc);
         return E_FAIL;
     }
 
     buffers = HeapAlloc(GetProcessHeap(), 0, size);
     if(!buffers){
-        HeapFree(GetProcessHeap(), 0, fmt);
+        CoTaskMemFree(fmt);
         return E_OUTOFMEMORY;
     }
 
     sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL,
             &size, buffers);
     if(sc != noErr){
-        HeapFree(GetProcessHeap(), 0, fmt);
+        CoTaskMemFree(fmt);
         HeapFree(GetProcessHeap(), 0, buffers);
         WARN("Unable to get _StreamConfiguration property: %lx\n", sc);
         return E_FAIL;
@@ -1202,7 +1201,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
     size = sizeof(Float64);
     sc = AudioObjectGetPropertyData(This->adevid, &addr, 0, NULL, &size, &rate);
     if(sc != noErr){
-        HeapFree(GetProcessHeap(), 0, fmt);
+        CoTaskMemFree(fmt);
         WARN("Unable to get _NominalSampleRate property: %lx\n", sc);
         return E_FAIL;
     }
@@ -1221,6 +1220,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient *iface,
     fmt->Samples.wValidBitsPerSample = fmt->Format.wBitsPerSample;
     fmt->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
 
+    *pwfx = (WAVEFORMATEX*)fmt;
     dump_fmt(*pwfx);
 
     return S_OK;




More information about the wine-cvs mailing list