From bf2b49b4e0ab46bff6a2f85f66be60d2ee320d9e Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Mon, 21 May 2007 16:43:44 +0100 Subject: [PATCH] ole32: Make proxy_manager_get_remunknown AddRef the return IRemUnknown object. Fix up the callers to release the returned IRemUnknown object. --- dlls/ole32/marshal.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dlls/ole32/marshal.c b/dlls/ole32/marshal.c index 759a6836b5a..9c7d53c6cb4 100644 --- a/dlls/ole32/marshal.c +++ b/dlls/ole32/marshal.c @@ -283,6 +283,7 @@ static HRESULT WINAPI ClientIdentity_QueryMultipleInterfaces(IMultiQI *iface, UL { hr = IRemUnknown_RemQueryInterface(remunk, ipid, NORMALEXTREFS, nonlocal_mqis, iids, &qiresults); + IRemUnknown_Release(remunk); if (FAILED(hr)) ERR("IRemUnknown_RemQueryInterface failed with error 0x%08x\n", hr); } @@ -409,6 +410,7 @@ static HRESULT WINAPI Proxy_MarshalInterface( rif.cPublicRefs = (mshlflags == MSHLFLAGS_TABLESTRONG) ? 1 : NORMALEXTREFS; rif.cPrivateRefs = 0; hr = IRemUnknown_RemAddRef(remunk, 1, &rif, &hrref); + IRemUnknown_Release(remunk); if (hr == S_OK && hrref == S_OK) { /* table-strong marshaling doesn't give the refs to the @@ -467,6 +469,7 @@ static HRESULT WINAPI Proxy_MarshalInterface( } else ERR("IRemUnknown_RemQueryInterface failed with error 0x%08x\n", hr); + IRemUnknown_Release(remunk); } } @@ -577,6 +580,7 @@ static HRESULT ifproxy_get_public_ref(struct ifproxy * This) rif.cPublicRefs = NORMALEXTREFS; rif.cPrivateRefs = 0; hr = IRemUnknown_RemAddRef(remunk, 1, &rif, &hrref); + IRemUnknown_Release(remunk); if (hr == S_OK && hrref == S_OK) InterlockedExchangeAdd((LONG *)&This->refs, NORMALEXTREFS); else @@ -614,6 +618,7 @@ static HRESULT ifproxy_release_public_refs(struct ifproxy * This) rif.cPublicRefs = public_refs; rif.cPrivateRefs = 0; hr = IRemUnknown_RemRelease(remunk, 1, &rif); + IRemUnknown_Release(remunk); if (hr == S_OK) InterlockedExchangeAdd((LONG *)&This->refs, -public_refs); else if (hr == RPC_E_DISCONNECTED) @@ -967,8 +972,11 @@ static HRESULT proxy_manager_get_remunknown(struct proxy_manager * This, IRemUnk EnterCriticalSection(&This->cs); if (This->remunk) + { /* already created - return existing object */ *remunk = This->remunk; + IRemUnknown_AddRef(*remunk); + } else if (!This->parent) /* disconnected - we can't create IRemUnknown */ hr = S_FALSE; @@ -988,9 +996,12 @@ static HRESULT proxy_manager_get_remunknown(struct proxy_manager * This, IRemUnk /* do the unmarshal */ hr = unmarshal_object(&stdobjref, This->parent, This->dest_context, This->dest_context_data, &IID_IRemUnknown, - &This->oxid_info, (void**)&This->remunk); + &This->oxid_info, (void**)remunk); if (hr == S_OK) - *remunk = This->remunk; + { + This->remunk = *remunk; + IRemUnknown_AddRef(This->remunk); + } } LeaveCriticalSection(&This->cs);