This is a slightly modified version of the original patch which releases the typelib reference on every ITypeInfo::Release(), not just when being destroyed. ChangeLog: Ensure TypeInfo objects always hold a reference on the containing TypeLib.
Index: dlls/oleaut32/typelib.c =================================================================== RCS file: /home/wine/wine/dlls/oleaut32/typelib.c,v retrieving revision 1.96 diff -u -r1.96 typelib.c --- dlls/oleaut32/typelib.c 15 May 2003 22:58:17 -0000 1.96 +++ dlls/oleaut32/typelib.c 17 Jun 2003 17:42:21 -0000 @@ -3359,6 +3359,8 @@ *ppTInfo = (ITypeInfo*)pTypeInfo; ITypeInfo_AddRef(*ppTInfo); + /* the TypeInfo object has a reference to us, so increment our own refcount */ + ITypeLib2_AddRef(iface); return S_OK; } @@ -3811,6 +3813,8 @@ --(This->ref); TRACE("(%p)->(%u)\n",This, This->ref); + /* dec the refcount on the containing typelib */ + ITypeLib2_Release((ITypeLib2*)This->pTypeLib); if (!This->ref) { @@ -4793,13 +4797,13 @@ /* If a pointer is null, we simply ignore it, the ATL in particular passes pIndex as 0 */ if (pIndex) { *pIndex=This->index; - TRACE("returning pIndex=%d", *pIndex); + TRACE("returning pIndex=%d\n", *pIndex); } if (ppTLib) { *ppTLib=(LPTYPELIB )(This->pTypeLib); ITypeLib2_AddRef(*ppTLib); - TRACE("returning ppTLib=%p", *ppTLib); + TRACE("returning ppTLib=%p\n", *ppTLib); } return S_OK;