wshom.ocx: Properly update typeinfo refcount
Alexandre Julliard
julliard at winehq.org
Wed Nov 28 09:19:41 CST 2012
Nikolay Sivov <nsivov at codeweavers.com> writes:
> On 11/28/2012 17:43, Alexandre Julliard wrote:
>> Nikolay Sivov <nsivov at codeweavers.com> writes:
>>
>>> @@ -137,8 +137,13 @@ static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT
>>> static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
>>> {
>>> WshCollection *This = impl_from_IWshCollection(iface);
>>> + HRESULT hr;
>>> +
>>> TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
>>> - return get_typeinfo(IWshCollection_tid, ppTInfo);
>>> +
>>> + hr = get_typeinfo(IWshCollection_tid, ppTInfo);
>>> + ITypeInfo_AddRef(*ppTInfo);
>>> + return hr;
>> You'd need to check for error first, but the AddRef should really be in
>> get_typeinfo().
> I agree about error part. The reason why AddRef shouldn't be in
> get_typeinfo() is to avoid pointless AddRef/Release when pointer does
> not go out, and the only case when it's returned to caller is this
> GetTypeInfo() method.
Internal functions should follow COM conventions too, otherwise we'll
constantly run into reference counting bugs. AddRef is cheap.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list