Robert Shearman : OLE: Fix brokenness in typelib marshaller caused by dispinterface retval fix.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Dec 6 14:27:19 CST 2005


Module: wine
Branch: refs/heads/master
Commit: b0d8e06caf47a8e7aee32b89575f6740d1a39d7d
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=b0d8e06caf47a8e7aee32b89575f6740d1a39d7d

Author: Robert Shearman <rob at codeweavers.com>
Date:   Tue Dec  6 21:24:19 2005 +0100

OLE: Fix brokenness in typelib marshaller caused by dispinterface retval fix.
Fix more fallout from dispinterface retval patch: make typelib
marshaler use the internal function description so that it calls
dispinterface functions with the correct number of parameters again.
Also fixes some memory leaks caused by the fact that a corresponding
ReleaseXDesc function has to be called for each GetXDesc.

---

 dlls/oleaut32/tmarshal.c |   16 +++++++++-------
 dlls/oleaut32/typelib.c  |   38 +++++++++++++++++++++++++++-----------
 dlls/oleaut32/typelib.h  |    2 ++
 3 files changed, 38 insertions(+), 18 deletions(-)

diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c
index 0886fc3..50a9135 100644
--- a/dlls/oleaut32/tmarshal.c
+++ b/dlls/oleaut32/tmarshal.c
@@ -304,12 +304,12 @@ _get_typeinfo_for_iid(REFIID riid, IType
  */
 static int _nroffuncs(ITypeInfo *tinfo) {
     int 	n, max = 0;
-    FUNCDESC	*fdesc;
+    const FUNCDESC *fdesc;
     HRESULT	hres;
 
     n=0;
     while (1) {
-	hres = ITypeInfo_GetFuncDesc(tinfo,n,&fdesc);
+	hres = ITypeInfoImpl_GetInternalFuncDesc(tinfo,n,&fdesc);
 	if (hres)
 	    return max+1;
 	if (fdesc->oVft/4 > max)
@@ -1053,6 +1053,7 @@ deserialize_param(
 			    (DWORD*)(((LPBYTE)*arg)+vdesc->u.oInst),
 			    buf
 			);
+                        ITypeInfo2_ReleaseVarDesc(tinfo2, vdesc);
 		        if (debugout && (i<tattr->cVars-1)) TRACE_(olerelay)(",");
 		    }
 		    if (debugout) TRACE_(olerelay)("}");
@@ -1108,7 +1109,7 @@ deserialize_param(
 /* Searches function, also in inherited interfaces */
 static HRESULT
 _get_funcdesc(
-    ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
+    ITypeInfo *tinfo, int iMethod, ITypeInfo **tactual, const FUNCDESC **fdesc, BSTR *iname, BSTR *fname)
 {
     int i = 0, j = 0;
     HRESULT hres;
@@ -1120,7 +1121,8 @@ _get_funcdesc(
     ITypeInfo_AddRef(*tactual);
 
     while (1) {
-	hres = ITypeInfo_GetFuncDesc(tinfo, i, fdesc);
+	hres = ITypeInfoImpl_GetInternalFuncDesc(tinfo, i, fdesc);
+
 	if (hres) {
 	    ITypeInfo	*tinfo2;
 	    HREFTYPE	href;
@@ -1164,7 +1166,7 @@ static DWORD
 xCall(LPVOID retptr, int method, TMProxyImpl *tpinfo /*, args */)
 {
     DWORD		*args = ((DWORD*)&tpinfo)+1, *xargs;
-    FUNCDESC		*fdesc;
+    const FUNCDESC	*fdesc;
     HRESULT		hres;
     int			i, relaydeb = TRACE_ON(olerelay);
     marshal_state	buf;
@@ -1451,7 +1453,7 @@ PSFacBuf_CreateProxy(
     HRESULT	hres;
     ITypeInfo	*tinfo;
     int		i, nroffuncs;
-    FUNCDESC	*fdesc;
+    const FUNCDESC *fdesc;
     TMProxyImpl	*proxy;
     TYPEATTR	*typeattr;
 
@@ -1647,7 +1649,7 @@ TMStubImpl_Invoke(
     LPRPCSTUBBUFFER iface, RPCOLEMESSAGE* xmsg,IRpcChannelBuffer*rpcchanbuf)
 {
     int		i;
-    FUNCDESC	*fdesc;
+    const FUNCDESC *fdesc;
     TMStubImpl *This = (TMStubImpl *)iface;
     HRESULT	hres;
     DWORD	*args, res, *xargs, nrofargs;
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index b2f417e..ebf1903 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -4489,6 +4489,24 @@ static HRESULT TLB_AllocAndInitFuncDesc(
     return S_OK;
 }
 
+HRESULT ITypeInfoImpl_GetInternalFuncDesc( ITypeInfo *iface, UINT index, const FUNCDESC **ppFuncDesc )
+{
+    ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
+    const TLBFuncDesc *pFDesc;
+    int i;
+
+    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next)
+        ;
+
+    if (pFDesc)
+    {
+        *ppFuncDesc = &pFDesc->funcdesc;
+        return S_OK;
+    }
+
+    return E_INVALIDARG;
+}
+
 /* ITypeInfo::GetFuncDesc
  *
  * Retrieves the FUNCDESC structure that contains information about a
@@ -4499,21 +4517,19 @@ static HRESULT WINAPI ITypeInfo_fnGetFun
         LPFUNCDESC  *ppFuncDesc)
 {
     ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
-    int i;
-    const TLBFuncDesc *pFDesc;
+    const FUNCDESC *internal_funcdesc;
+    HRESULT hr;
 
     TRACE("(%p) index %d\n", This, index);
 
-    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next)
-        ;
-
-    if(pFDesc)
-        return TLB_AllocAndInitFuncDesc(
-            &pFDesc->funcdesc,
-            ppFuncDesc,
-            This->TypeAttr.typekind == TKIND_DISPATCH);
+    hr = ITypeInfoImpl_GetInternalFuncDesc((ITypeInfo *)iface, index, &internal_funcdesc);
+    if (FAILED(hr))
+        return hr;
 
-    return E_INVALIDARG;
+    return TLB_AllocAndInitFuncDesc(
+        internal_funcdesc,
+        ppFuncDesc,
+        This->TypeAttr.typekind == TKIND_DISPATCH);
 }
 
 static HRESULT TLB_AllocAndInitVarDesc( const VARDESC *src, VARDESC **dest_ptr )
diff --git a/dlls/oleaut32/typelib.h b/dlls/oleaut32/typelib.h
index 3bb6811..c286fae 100644
--- a/dlls/oleaut32/typelib.h
+++ b/dlls/oleaut32/typelib.h
@@ -600,6 +600,8 @@ WORD typeofarray
 
 #include "poppack.h"
 
+HRESULT ITypeInfoImpl_GetInternalFuncDesc( ITypeInfo *iface, UINT index, const FUNCDESC **ppFuncDesc );
+
 extern DWORD _invoke(FARPROC func,CALLCONV callconv, int nrargs, DWORD *args);
 extern void dump_Variant(const VARIANT * pvar);
 




More information about the wine-cvs mailing list