[PATCH] Remove potential reference count races

max at mtew.isa-geek.net max at mtew.isa-geek.net
Sat Oct 27 20:59:18 CDT 2012


From: Max TenEyck Woodbury <max at mtew.isa-geek.net>

---
 dlls/dsound/buffer.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index cf4d2ec..9f9f2ff 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -95,7 +95,7 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(IDirectSou
 
 	if (TRACE_ON(dsound)) {
 	    unsigned int	i;
-	    for (i=0;i<howmuch;i++)
+	    for (i=0;i<howmuch;++i)
 		TRACE("notify at %d to %p\n",
 		    notify[i].dwOffset,notify[i].hEventNotify);
 	}
@@ -666,7 +666,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetFX(IDirectSoundBuffer8 *iface, D
 	FIXME("(%p,%u,%p,%p): stub\n",This,dwEffectsCount,pDSFXDesc,pdwResultCodes);
 
 	if (pdwResultCodes)
-		for (u=0; u<dwEffectsCount; u++) pdwResultCodes[u] = DSFXR_UNKNOWN;
+		for (u=0; u<dwEffectsCount; ++u) pdwResultCodes[u] = DSFXR_UNKNOWN;
 
 	WARN("control unavailable\n");
 	return DSERR_CONTROLUNAVAIL;
@@ -681,7 +681,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_AcquireResources(IDirectSoundBuffer
 	FIXME("(%p,%08u,%u,%p): stub, faking success\n",This,dwFlags,dwEffectsCount,pdwResultCodes);
 
 	if (pdwResultCodes)
-		for (u=0; u<dwEffectsCount; u++) pdwResultCodes[u] = DSFXR_UNKNOWN;
+		for (u=0; u<dwEffectsCount; ++u) pdwResultCodes[u] = DSFXR_UNKNOWN;
 
 	WARN("control unavailable\n");
 	return DS_OK;
@@ -975,7 +975,7 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
     DirectSoundDevice_RemoveBuffer(This->device, This);
     RtlDeleteResource(&This->lock);
 
-    This->buffer->ref--;
+    InterlockedDecrement(&This->buffer->ref);
     list_remove(&This->entry);
     if (This->buffer->ref == 0) {
         HeapFree(GetProcessHeap(), 0, This->buffer->memory);
@@ -1019,7 +1019,7 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
         return DSERR_OUTOFMEMORY;
     }
 
-    dsb->buffer->ref++;
+    InterlockedIncrement(&dsb->buffer->ref);
     list_add_head(&dsb->buffer->buffers, &dsb->entry);
     dsb->ref = 0;
     dsb->refn = 0;
@@ -1040,7 +1040,7 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
     if (hres != DS_OK) {
         RtlDeleteResource(&dsb->lock);
         list_remove(&dsb->entry);
-        dsb->buffer->ref--;
+        InterlockedDecrement(&dsb->buffer->ref);
         HeapFree(GetProcessHeap(),0,dsb->pwfx);
         HeapFree(GetProcessHeap(),0,dsb);
         dsb = NULL;
-- 
1.7.7.6




More information about the wine-patches mailing list