From 37e386279991f966281f92bdbe6a7c37c5715ecb Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sun, 12 Aug 2007 17:41:15 +0200 Subject: [PATCH] mshtml: Make get_typeinfo thread safe. --- dlls/mshtml/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c index 6ed2549b38c..e0645f89644 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];