From ef860c3e5af11c844ef0e329c425d8db94a8527f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 31 Jul 2011 14:10:37 -0700 Subject: [PATCH] Protect the primary buffer when modifying it during secondary buffer destruction --- buffer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/buffer.c b/buffer.c index def6342..26e97f8 100644 --- a/buffer.c +++ b/buffer.c @@ -702,6 +702,7 @@ void DS8Buffer_Destroy(DS8Buffer *This) TRACE("Destroying %p\n", This); + EnterCriticalSection(&prim->crst); /* Remove from list, if in list */ for(idx = 0;idx < prim->nnotifies;++idx) { @@ -743,12 +744,16 @@ void DS8Buffer_Destroy(DS8Buffer *This) sources[prim->nsources++] = This->source; prim->sources = sources; } + This->source = 0; } - HeapFree(GetProcessHeap(), 0, This->notify); - This->source = 0; + LeaveCriticalSection(&prim->crst); + if(This->buffer) DS8Data_Release(This->buffer); + popALContext(); + + HeapFree(GetProcessHeap(), 0, This->notify); HeapFree(GetProcessHeap(), 0, This); } -- 2.11.4.GIT