Vincent Povirk : windowscodecs: Make IWICStream thread-safe.

Alexandre Julliard julliard at winehq.org
Mon Apr 12 09:54:07 CDT 2010


Module: wine
Branch: master
Commit: a6bf1287bae2c29908821de2fef7dc043d1153dc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a6bf1287bae2c29908821de2fef7dc043d1153dc

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri Apr  9 11:04:00 2010 -0500

windowscodecs: Make IWICStream thread-safe.

---

 dlls/windowscodecs/stream.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/dlls/windowscodecs/stream.c b/dlls/windowscodecs/stream.c
index f3be0c3..24eaf87 100644
--- a/dlls/windowscodecs/stream.c
+++ b/dlls/windowscodecs/stream.c
@@ -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;
 }
 




More information about the wine-cvs mailing list