Jacek Caban : mshtml: Make get_typeinfo thread safe.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 13 06:31:44 CDT 2007


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Aug 12 17:41:15 2007 +0200

mshtml: Make get_typeinfo thread safe.

---

 dlls/mshtml/main.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index 6ed2549..e0645f8 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -63,19 +63,29 @@ HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
     HRESULT hres;
 
     if(!typelib) {
-        hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
+        ITypeLib *tl;
+
+        hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &tl);
         if(FAILED(hres)) {
             ERR("LoadRegTypeLib failed: %08x\n", hres);
             return hres;
         }
+
+        if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
+            ITypeLib_Release(tl);
     }
 
     if(!typeinfos[tid]) {
-        hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], typeinfos+tid);
+        ITypeInfo *typeinfo;
+
+        hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &typeinfo);
         if(FAILED(hres)) {
             ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
             return hres;
         }
+
+        if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), typeinfo, NULL))
+            ITypeInfo_Release(typeinfo);
     }
 
     *typeinfo = typeinfos[tid];




More information about the wine-cvs mailing list