Commit e119aceb authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleaut32: Fix some reference leaks.

parent 3c747fec
...@@ -1425,19 +1425,19 @@ static void test_CreateTypeLib(void) { ...@@ -1425,19 +1425,19 @@ static void test_CreateTypeLib(void) {
hres = ICreateTypeLib2_SaveAllChanges(createtl); hres = ICreateTypeLib2_SaveAllChanges(createtl);
ok(hres == S_OK, "got %08x\n", hres); ok(hres == S_OK, "got %08x\n", hres);
ICreateTypeLib2_Release(createtl);
hres = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl); hres = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl);
ok(hres == S_OK, "got %08x\n", hres); ok(hres == S_OK, "got %08x\n", hres);
ITypeInfo_Release(interface2); ok(ITypeInfo_Release(interface2)==0, "Object should be freed\n");
ITypeInfo_Release(interface1); ok(ITypeInfo_Release(interface1)==0, "Object should be freed\n");
ITypeInfo_Release(dual); ok(ITypeInfo_Release(dual)==0, "Object should be freed\n");
ITypeInfo_Release(dispatch); ok(ICreateTypeLib2_Release(createtl)==0, "Object should be freed\n");
ITypeInfo_Release(unknown); ok(ITypeInfo_Release(dispatch)==0, "Object should be freed\n");
ok(ITypeInfo_Release(unknown)==0, "Object should be freed\n");
ITypeLib_Release(tl); ok(ITypeLib_Release(tl)==0, "Object should be freed\n");
ITypeLib_Release(stdole); ok(ITypeLib_Release(stdole)==0, "Object should be freed\n");
DeleteFileA(filename); DeleteFileA(filename);
} }
......
...@@ -1315,7 +1315,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnQueryInterface( ...@@ -1315,7 +1315,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnQueryInterface(
if(*ppvObject) if(*ppvObject)
{ {
ICreateTypeLib2_AddRef(iface); ICreateTypeInfo2_AddRef(iface);
TRACE("-- Interface: (%p)->(%p)\n",ppvObject,*ppvObject); TRACE("-- Interface: (%p)->(%p)\n",ppvObject,*ppvObject);
return S_OK; return S_OK;
} }
...@@ -1583,8 +1583,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( ...@@ -1583,8 +1583,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
/* Allocate container GUID */ /* Allocate container GUID */
hres = ITypeLib_GetLibAttr(container, &tlibattr); hres = ITypeLib_GetLibAttr(container, &tlibattr);
if(FAILED(hres)) if(FAILED(hres)) {
ITypeLib_Release(container);
return hres; return hres;
}
guid.guid = tlibattr->guid; guid.guid = tlibattr->guid;
guid.hreftype = This->typelib->typelib_guids*12+2; guid.hreftype = This->typelib->typelib_guids*12+2;
...@@ -1593,6 +1595,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( ...@@ -1593,6 +1595,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
guid_offset = ctl2_alloc_guid(This->typelib, &guid); guid_offset = ctl2_alloc_guid(This->typelib, &guid);
if(guid_offset == -1) { if(guid_offset == -1) {
ITypeLib_ReleaseTLibAttr(container, tlibattr); ITypeLib_ReleaseTLibAttr(container, tlibattr);
ITypeLib_Release(container);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -1613,6 +1616,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( ...@@ -1613,6 +1616,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
|| (p=strrchrW(name, '\\'))==NULL) { || (p=strrchrW(name, '\\'))==NULL) {
ERR("Error guessing typelib filename\n"); ERR("Error guessing typelib filename\n");
ITypeLib_ReleaseTLibAttr(container, tlibattr); ITypeLib_ReleaseTLibAttr(container, tlibattr);
ITypeLib_Release(container);
return E_NOTIMPL; return E_NOTIMPL;
} }
memmove(name, p+1, strlenW(p)*sizeof(WCHAR)); memmove(name, p+1, strlenW(p)*sizeof(WCHAR));
...@@ -1622,13 +1626,17 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( ...@@ -1622,13 +1626,17 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
tlibattr->lcid, tlibattr->wMajorVerNum, tlibattr->wMinorVerNum, name); tlibattr->lcid, tlibattr->wMajorVerNum, tlibattr->wMinorVerNum, name);
ITypeLib_ReleaseTLibAttr(container, tlibattr); ITypeLib_ReleaseTLibAttr(container, tlibattr);
if(import_offset == -1) if(import_offset == -1) {
ITypeLib_Release(container);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
/* Allocate referenced guid */ /* Allocate referenced guid */
hres = ITypeInfo_GetTypeAttr(pTInfo, &typeattr); hres = ITypeInfo_GetTypeAttr(pTInfo, &typeattr);
if(FAILED(hres)) if(FAILED(hres)) {
ITypeLib_Release(container);
return hres; return hres;
}
guid.guid = typeattr->guid; guid.guid = typeattr->guid;
guid.hreftype = This->typelib->typeinfo_guids*12+1; guid.hreftype = This->typelib->typeinfo_guids*12+1;
...@@ -1636,8 +1644,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo( ...@@ -1636,8 +1644,10 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddRefTypeInfo(
ITypeInfo_ReleaseTypeAttr(pTInfo, typeattr); ITypeInfo_ReleaseTypeAttr(pTInfo, typeattr);
guid_offset = ctl2_alloc_guid(This->typelib, &guid); guid_offset = ctl2_alloc_guid(This->typelib, &guid);
if(guid_offset == -1) if(guid_offset == -1) {
ITypeLib_Release(container);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
check_guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][guid_offset]; check_guid = (MSFT_GuidEntry*)&This->typelib->typelib_segment_data[MSFT_SEG_GUID][guid_offset];
if(check_guid->hreftype == guid.hreftype) if(check_guid->hreftype == guid.hreftype)
...@@ -2390,15 +2400,17 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( ...@@ -2390,15 +2400,17 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut(
return hres; return hres;
hres = ITypeInfo_GetRefTypeInfo(next, hreftype, &cur); hres = ITypeInfo_GetRefTypeInfo(next, hreftype, &cur);
ITypeInfo_Release(next);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
ITypeInfo_Release(next);
while(1) { while(1) {
hres = ITypeInfo_GetTypeAttr(cur, &typeattr); hres = ITypeInfo_GetTypeAttr(cur, &typeattr);
if(FAILED(hres)) if(FAILED(hres)) {
ITypeInfo_Release(cur);
return hres; return hres;
}
if(!memcmp(&typeattr->guid, &IID_IDispatch, sizeof(IDispatch))) if(!memcmp(&typeattr->guid, &IID_IDispatch, sizeof(IDispatch)))
This->typeinfo->flags |= TYPEFLAG_FDISPATCHABLE; This->typeinfo->flags |= TYPEFLAG_FDISPATCHABLE;
...@@ -2409,16 +2421,21 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut( ...@@ -2409,16 +2421,21 @@ static HRESULT WINAPI ICreateTypeInfo2_fnLayOut(
hres = ITypeInfo_GetRefTypeOfImplType(cur, 0, &hreftype); hres = ITypeInfo_GetRefTypeOfImplType(cur, 0, &hreftype);
if(hres == TYPE_E_ELEMENTNOTFOUND) if(hres == TYPE_E_ELEMENTNOTFOUND)
break; break;
if(FAILED(hres)) if(FAILED(hres)) {
ITypeInfo_Release(cur);
return hres; return hres;
}
hres = ITypeInfo_GetRefTypeInfo(cur, hreftype, &next); hres = ITypeInfo_GetRefTypeInfo(cur, hreftype, &next);
if(FAILED(hres)) if(FAILED(hres)) {
ITypeInfo_Release(cur);
return hres; return hres;
}
ITypeInfo_Release(cur); ITypeInfo_Release(cur);
cur = next; cur = next;
} }
ITypeInfo_Release(cur);
} }
This->typeinfo->cbSizeVft = (This->typeinfo->datatype2>>16) * 4; This->typeinfo->cbSizeVft = (This->typeinfo->datatype2>>16) * 4;
...@@ -3102,6 +3119,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo( ...@@ -3102,6 +3119,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetRefTypeInfo(
if(hRefType==-2 && This->dual) { if(hRefType==-2 && This->dual) {
*ppTInfo = (ITypeInfo*)&This->dual->lpVtblTypeInfo2; *ppTInfo = (ITypeInfo*)&This->dual->lpVtblTypeInfo2;
ITypeInfo_AddRef(*ppTInfo);
return S_OK; return S_OK;
} }
...@@ -3207,7 +3225,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetContainingTypeLib( ...@@ -3207,7 +3225,7 @@ static HRESULT WINAPI ITypeInfo2_fnGetContainingTypeLib(
TRACE("(%p,%p,%p)\n", iface, ppTLib, pIndex); TRACE("(%p,%p,%p)\n", iface, ppTLib, pIndex);
*ppTLib = (ITypeLib *)&This->typelib->lpVtblTypeLib2; *ppTLib = (ITypeLib *)&This->typelib->lpVtblTypeLib2;
This->typelib->ref++; ICreateTypeLib_AddRef((ICreateTypeLib*)This->typelib);
*pIndex = This->typeinfo->typekind >> 16; *pIndex = This->typeinfo->typekind >> 16;
return S_OK; return S_OK;
...@@ -3656,7 +3674,7 @@ static ICreateTypeInfo2 *ICreateTypeInfo2_Constructor(ICreateTypeLib2Impl *typel ...@@ -3656,7 +3674,7 @@ static ICreateTypeInfo2 *ICreateTypeInfo2_Constructor(ICreateTypeLib2Impl *typel
pCreateTypeInfo2Impl->ref = 1; pCreateTypeInfo2Impl->ref = 1;
pCreateTypeInfo2Impl->typelib = typelib; pCreateTypeInfo2Impl->typelib = typelib;
typelib->ref++; ICreateTypeLib_AddRef((ICreateTypeLib*)typelib);
nameoffset = ctl2_alloc_name(typelib, szName); nameoffset = ctl2_alloc_name(typelib, szName);
typeinfo_offset = ctl2_alloc_typeinfo(typelib, nameoffset); typeinfo_offset = ctl2_alloc_typeinfo(typelib, nameoffset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment