windowscodecs: Make IWICStream thread-safe.

This commit is contained in:
Vincent Povirk 2010-04-09 11:04:00 -05:00 committed by Alexandre Julliard
parent 40d48e674e
commit a6bf1287ba
1 changed files with 7 additions and 1 deletions

View File

@ -477,7 +477,13 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface,
InitializeCriticalSection(&pObject->lock);
pObject->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StreamOnMemory.lock");
This->pStream = (IStream*)pObject;
if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
{
/* Some other thread set the stream first. */
IStream_Release((IStream*)pObject);
return WINCODEC_ERR_WRONGSTATE;
}
return S_OK;
}