<>You're right to be suspicious, and there may actually be a bug with the reference counting in typelib2.c, but fnGetTypeInfoOfGuid should -not- directly AddRef() the containing typelib. Such an AddRef() rightfully belongs in with the implemetations of QueryInterface(), AddRef(), and Release() on ICreateTypeInfo2. It is supposed to be set up that the TypeInfo objects never deallocate themselves when they hit 0 references, but they do hold a reference to their containing typelib. The TypeLib objects never hold a reference to any of their typeinfos (so as not to cause a reference cycle), but they are set up to deallocate the typeinfo structures when the typelib hits 0 references.
Application can use fnGetTypeInfoOfGuid function to get ITypeInfo, next release ITypeLib and still use ITypeInfo, so GetTypeInfoOfGuid must directly AddRef the contaning typelib. See this patch: http://www.winehq.org/hypermail/wine-patches/2004/08/0167.html and test "typelib". I think similar thing should be done in typelib2.c.
Jacek