From 7deab426098c7b920a9820449c286abcb5e8c7ba Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Mon, 16 Aug 2004 21:07:22 +0000 Subject: [PATCH] Fix potential race in IPinImpl_ConnectedTo. --- dlls/quartz/pin.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 447581b0dd4..3e946cf7d95 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -247,19 +247,25 @@ HRESULT WINAPI IPinImpl_Disconnect(IPin * iface) 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) -- 2.11.4.GIT