Andrew Eikum : xaudio2: Protect access to source voice during creation ( Coverity).
Module: wine Branch: stable Commit: 6c50c182e6e03a63a93c2df7a92abea5d8ccb20a URL: http://source.winehq.org/git/wine.git/?a=commit;h=6c50c182e6e03a63a93c2df7a9... Author: Andrew Eikum <aeikum(a)codeweavers.com> Date: Wed Feb 10 12:54:25 2016 -0600 xaudio2: Protect access to source voice during creation (Coverity). Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> (cherry picked from commit 2c82e8b477fe476b2eb3ad4452225619ca2e7a58) Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- 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 a2e3ef5..2f750bd 100644 --- a/dlls/xaudio2_7/xaudio_dll.c +++ b/dlls/xaudio2_7/xaudio_dll.c @@ -1364,8 +1364,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){ @@ -1386,6 +1388,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; @@ -1398,6 +1402,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; } @@ -1410,6 +1415,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; } @@ -1420,6 +1426,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; } @@ -1427,6 +1434,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
participants (1)
-
Alexandre Julliard