[DSOUND] Bug 3514 fix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[DSOUND] Bug 3514 fix

Robert Reif
Fix PrimaryBufferImpl pointer to deleted DirectSoundImpl.

Index: dlls/dsound/dsound.c
===================================================================
RCS file: /home/wine/wine/dlls/dsound/dsound.c,v
retrieving revision 1.39
diff -p -u -r1.39 dsound.c
--- dlls/dsound/dsound.c 10 Oct 2005 10:29:13 -0000 1.39
+++ dlls/dsound/dsound.c 10 Oct 2005 22:53:17 -0000
@@ -247,9 +247,13 @@ static ULONG WINAPI IDirectSoundImpl_Rel
     TRACE("(%p) ref was %ld\n", This, ref + 1);
 
     if (!ref) {
-        if (This->device)
-            DirectSoundDevice_Release(This->device);
-
+        if (This->device) {
+            if (DirectSoundDevice_Release(This->device) != 0) {
+                /* device not released so make sure primary reference to This removed */
+                if (This->device->primary)
+                    This->device->primary->dsound = NULL;
+            }
+        }
         HeapFree(GetProcessHeap(),0,This);
         TRACE("(%p) released\n", This);
     }
@@ -325,6 +329,7 @@ static HRESULT WINAPI DSOUND_CreateSound
             WARN("Primary Buffer already created\n");
             IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(This->device->primary));
             *ppdsb = (LPDIRECTSOUNDBUFFER)(This->device->primary);
+            This->device->primary->dsound = This;
         } else {
            This->device->dsbd = *dsbd;
            hres = PrimaryBufferImpl_Create(This, (PrimaryBufferImpl**)&(This->device->primary), &(This->device->dsbd));