Module: wine Branch: refs/heads/master Commit: 875390110f55dfba2b2819b141cf1701e2302dce URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=875390110f55dfba2b2819b1...
Author: Robert Shearman rob@codeweavers.com Date: Mon May 22 22:17:13 2006 +0100
ole32: Release the proxy buffer object on the last release of the proxy's outer unknown.
Release the proxy buffer object on the last release of the proxy's outer unknown, otherwise memory is leaked for the Ndr implementation of IRpcProxyBuffer.
Fix up the hand-coded proxies to match the behaviour from the Ndr implementation.
---
dlls/ole32/marshal.c | 4 +--- dlls/ole32/oleproxy.c | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/dlls/ole32/marshal.c b/dlls/ole32/marshal.c index 976d9e7..76744c6 100644 --- a/dlls/ole32/marshal.c +++ b/dlls/ole32/marshal.c @@ -543,9 +543,7 @@ static void ifproxy_destroy(struct ifpro This->chan = NULL; }
- /* note: we don't call Release for This->proxy because its lifetime is - * controlled by the return value from ClientIdentity_Release, which this - * function is always called from */ + if (This->proxy) IRpcProxyBuffer_Release(This->proxy);
HeapFree(GetProcessHeap(), 0, This); } diff --git a/dlls/ole32/oleproxy.c b/dlls/ole32/oleproxy.c index 98df7d8..dae097e 100644 --- a/dlls/ole32/oleproxy.c +++ b/dlls/ole32/oleproxy.c @@ -66,6 +66,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); const CLSID CLSID_DfMarshal = { 0x0000030b, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} }; const CLSID CLSID_PSFactoryBuffer = { 0x00000320, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
+static ULONG WINAPI RURpcProxyBufferImpl_Release(LPRPCPROXYBUFFER iface); + /* From: http://msdn.microsoft.com/library/en-us/com/cmi_m_4lda.asp * * The first time a client requests a pointer to an interface on a @@ -345,18 +347,11 @@ static ULONG WINAPI CFProxy_AddRef(LPC }
static ULONG WINAPI CFProxy_Release(LPCLASSFACTORY iface) { - ULONG ref; ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface); if (This->outer_unknown) - ref = IUnknown_Release(This->outer_unknown); - else - ref = InterlockedDecrement(&This->ref); - - if (!ref) { - if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf); - HeapFree(GetProcessHeap(),0,This); - } - return ref; + return IUnknown_Release(This->outer_unknown); + else + return IRpcProxyBufferImpl_Release((IRpcProxyBuffer *)&This->lpvtbl_proxy); }
static HRESULT WINAPI CFProxy_CreateInstance( @@ -712,19 +707,12 @@ static ULONG WINAPI RemUnkProxy_AddRef(L static ULONG WINAPI RemUnkProxy_Release(LPREMUNKNOWN iface) { RemUnkProxy *This = (RemUnkProxy *)iface; - ULONG refs;
TRACE("(%p)->Release()\n",This); if (This->outer_unknown) - refs = IUnknown_Release(This->outer_unknown); - else - refs = InterlockedDecrement(&This->refs); - - if (!refs) { - if (This->chan) IRpcChannelBuffer_Release(This->chan); - HeapFree(GetProcessHeap(),0,This); - } - return refs; + return IUnknown_Release(This->outer_unknown); + else + return IRpcProxyBufferImpl_Release((IRpcProxyBuffer *)&This->lpvtbl_proxy); }
static HRESULT WINAPI RemUnkProxy_RemQueryInterface(LPREMUNKNOWN iface,