Hi, Malte Starostik submitted this patch to wine-patches on "Sat Oct 13 2001 - 08:11:00 EDT". While not 100% correct, it fixes a very unfunny problem with a typelib using program I have, so please apply. :) His mail (http://www.winehq.com/hypermail/wine-patches/2001/10/0086.html) > This makes sure the ITypeLib held by ITypeInfo isn't destroyed before > the type info is, as happened in reaktivate. There, the IProvideClassInfo > interface of the loaded control would load the type lib, release it and > then the returned ITypeInfo referenced this freed typelib. > > However, now the type lib isn't freed at all, which seems to me to be caused > by ITypeInfoImpl's reflist never being freed, and therefore the ITypeLibs > referenced there are not released. I don't grok enough of this code to check > where that should be done properly though :( Ciao, Marcus Changelog: Malte Starostik <malte@kde.org> Do not destroy ITypeLib held by ITypeInfo before the latter is freed. Index: typelib.c =================================================================== RCS file: /home/wine/wine/dlls/oleaut32/typelib.c,v retrieving revision 1.53 diff -u -3 -d -p -r1.53 typelib.c --- typelib.c 2001/10/05 19:37:44 1.53 +++ typelib.c 2001/10/13 10:45:23 @@ -1684,6 +1684,7 @@ ITypeInfoImpl * MSFT_DoTypeInfo( pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase)); /* this is where we are coming from */ ptiRet->pTypeLib = pLibInfo; + ITypeLib2_AddRef((ITypeLib2 *)pLibInfo); ptiRet->index=count; /* fill in the typeattr fields */ FIXME("Assign constructor/destructor memid\n"); @@ -2821,6 +2822,7 @@ static ITypeLib2* ITypeLib2_Constructor_ } *ppTypeInfoImpl = (ITypeInfoImpl*)ITypeInfo_Constructor(); (*ppTypeInfoImpl)->pTypeLib = pTypeLibImpl; + ITypeLib2_AddRef((ITypeLib2 *)pTypeLibImpl); (*ppTypeInfoImpl)->index = i; (*ppTypeInfoImpl)->Name = TLB_MultiByteToBSTR( pOtherTypeInfoBlks[i].name_offs + @@ -4144,7 +4146,7 @@ static HRESULT WINAPI ITypeInfo_fnGetRef if(!pRefType) FIXME("Can't find pRefType for ref %lx\n", hRefType); if(pRefType && hRefType != -1) { - ITypeLib *pTLib; + ITypeLib *pTLib = NULL; if(pRefType->pImpTLInfo == TLB_REF_INTERNAL) { int Index; @@ -4183,6 +4185,8 @@ static HRESULT WINAPI ITypeInfo_fnGetRef result = ITypeLib2_GetTypeInfo(pTLib, pRefType->index, ppTInfo); } + if (pTypeLib != NULL) + ITypeLib2_Release(pTLib); } }