[PATCH 1/2 (try2)] xaudio2: Protect access to source voice during creation (Coverity).
Andrew Eikum
aeikum at codeweavers.com
Wed Feb 10 12:54:25 CST 2016
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
CID 1339907
---
dlls/xaudio2_7/xaudio_dll.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dlls/xaudio2_7/xaudio_dll.c b/dlls/xaudio2_7/xaudio_dll.c
index 6d766a1..0c39354 100644
--- a/dlls/xaudio2_7/xaudio_dll.c
+++ b/dlls/xaudio2_7/xaudio_dll.c
@@ -1367,8 +1367,10 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
EnterCriticalSection(&This->lock);
LIST_FOR_EACH_ENTRY(src, &This->source_voices, XA2SourceImpl, entry){
+ EnterCriticalSection(&src->lock);
if(!src->in_use)
break;
+ LeaveCriticalSection(&src->lock);
}
if(&src->entry == &This->source_voices){
@@ -1394,6 +1396,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
src->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": XA2SourceImpl.lock");
src->xa2 = This;
+
+ EnterCriticalSection(&src->lock);
}
src->in_use = TRUE;
@@ -1406,6 +1410,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
src->al_fmt = get_al_format(pSourceFormat);
if(!src->al_fmt){
src->in_use = FALSE;
+ LeaveCriticalSection(&src->lock);
WARN("OpenAL can't convert this format!\n");
return AUDCLNT_E_UNSUPPORTED_FORMAT;
}
@@ -1418,6 +1423,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
if(FAILED(hr)){
HeapFree(GetProcessHeap(), 0, src->fmt);
src->in_use = FALSE;
+ LeaveCriticalSection(&src->lock);
return hr;
}
@@ -1428,6 +1434,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
ERR_(winediag)("OpenAL ran out of sources, consider increasing its source limit.\n");
HeapFree(GetProcessHeap(), 0, src->fmt);
src->in_use = FALSE;
+ LeaveCriticalSection(&src->lock);
return E_OUTOFMEMORY;
}
@@ -1435,6 +1442,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
alSourcePlay(src->al_src);
+ LeaveCriticalSection(&src->lock);
+
#if XAUDIO2_VER == 0
*ppSourceVoice = (IXAudio2SourceVoice*)&src->IXAudio20SourceVoice_iface;
#elif XAUDIO2_VER <= 3
--
2.7.1
More information about the wine-patches
mailing list