Alistair Leslie-Hughes leslie_alistair@hotmail.com writes:
+HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) +{
- HRESULT hres;
- if(!typelib) {
ITypeLib *tl;hres = LoadRegTypeLib(&LIBID_MSXML2, 3, 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]) {
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];
- return S_OK;
You should increment the ref count when you are returning a pointer, even if it's also stored in a global variable.