Quartz: Fix Potential Race
Robert Shearman
rob at codeweavers.com
Sat Aug 14 21:57:22 CDT 2004
Fixes nasty race that could cause subtle memory corruption or hard to
reproduce crashes due to This->pConnectedTo potentially being destroyed
by another thread disconnecting the pin.
Changelog:
Fix potential race in IPinImpl_ConnectedTo
-------------- next part --------------
Index: wine/dlls/quartz/pin.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/pin.c,v
retrieving revision 1.3
diff -u -r1.3 pin.c
--- wine/dlls/quartz/pin.c 18 Nov 2003 20:47:48 -0000 1.3
+++ wine/dlls/quartz/pin.c 14 Aug 2004 14:01:48 -0000
@@ -247,19 +247,25 @@
HRESULT WINAPI IPinImpl_ConnectedTo(IPin * iface, IPin ** ppPin)
{
+ HRESULT hr;
ICOM_THIS(IPinImpl, iface);
/* TRACE("(%p)\n", ppPin);*/
- *ppPin = This->pConnectedTo;
-
- if (*ppPin)
+ EnterCriticalSection(This->pCritSec);
{
- IPin_AddRef(*ppPin);
- return S_OK;
+ if (This->pConnectedTo)
+ {
+ *ppPin = This->pConnectedTo;
+ IPin_AddRef(*ppPin);
+ hr = S_OK;
+ }
+ else
+ hr = VFW_E_NOT_CONNECTED;
}
- else
- return VFW_E_NOT_CONNECTED;
+ LeaveCriticalSection(This->pCritSec);
+
+ return hr;
}
HRESULT WINAPI IPinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt)
More information about the wine-patches
mailing list