Fix potential race in IPinImpl_ConnectedTo.

This commit is contained in:
Robert Shearman 2004-08-16 21:07:22 +00:00 committed by Alexandre Julliard
parent c626491bf1
commit 7deab42609
1 changed files with 13 additions and 7 deletions

View File

@ -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)