[PATCH 2/2] xaudio2: Protect access to submix voice during creation (Coverity).

Andrew Eikum aeikum at codeweavers.com
Wed Feb 10 11:22:43 CST 2016


---

CID 1339908

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
 dlls/xaudio2_7/xaudio_dll.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dlls/xaudio2_7/xaudio_dll.c b/dlls/xaudio2_7/xaudio_dll.c
index 0c39354..503c974 100644
--- a/dlls/xaudio2_7/xaudio_dll.c
+++ b/dlls/xaudio2_7/xaudio_dll.c
@@ -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;
-- 
2.7.1





More information about the wine-patches mailing list