xaudio2: Protect access to submix voice during creation (Coverity).

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2016-02-10 12:54:40 -06:00 committed by Alexandre Julliard
parent 2c82e8b477
commit 7bb885a3d3
1 changed files with 5 additions and 0 deletions

View File

@ -1475,8 +1475,10 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
EnterCriticalSection(&This->lock);
LIST_FOR_EACH_ENTRY(sub, &This->submix_voices, XA2SubmixImpl, entry){
EnterCriticalSection(&sub->lock);
if(!sub->in_use)
break;
LeaveCriticalSection(&sub->lock);
}
if(&sub->entry == &This->submix_voices){
@ -1498,11 +1500,14 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
InitializeCriticalSection(&sub->lock);
sub->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": XA2SubmixImpl.lock");
EnterCriticalSection(&sub->lock);
}
sub->in_use = TRUE;
LeaveCriticalSection(&This->lock);
LeaveCriticalSection(&sub->lock);
#if XAUDIO2_VER == 0
*ppSubmixVoice = (IXAudio2SubmixVoice*)&sub->IXAudio20SubmixVoice_iface;