wine/dlls/oleaut32 typelib.c

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 1 06:02:09 CST 2005


ChangeSet ID:	21597
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/12/01 06:02:09

Modified files:
	dlls/oleaut32  : typelib.c 

Log message:
	Robert Shearman <rob at codeweavers.com>
	Remove broken return value handling code and that would reference
	memory beyond the end of the arguments array. Replace it with code
	that properly handles referencing the return type and setting the
	return type to VT_VOID when a dispinterface function doesn't have any
	return value.

Patch: http://cvs.winehq.org/patch.py?id=21597

Old revision  New revision  Changes     Path
 1.182         1.183         +27 -32     wine/dlls/oleaut32/typelib.c

Index: wine/dlls/oleaut32/typelib.c
diff -u -p wine/dlls/oleaut32/typelib.c:1.182 wine/dlls/oleaut32/typelib.c:1.183
--- wine/dlls/oleaut32/typelib.c:1.182	1 Dec 2005 12: 2: 9 -0000
+++ wine/dlls/oleaut32/typelib.c	1 Dec 2005 12: 2: 9 -0000
@@ -1861,43 +1861,38 @@ MSFT_DoFuncs(TLBContext*     pcx,
 			   recoffset + reclength - ((pFuncRec->nrargs - j - 1)
 					       * sizeof(MSFT_ParameterInfo)));
             }
+        }
 
-            /* parameter is the return value! */
-            if ( paraminfo.Flags & PARAMFLAG_FRETVAL )
+        /* special treatment for dispinterfaces: this makes functions appear
+         * to return their [retval] value when it is really returning an
+         * HRESULT */
+        if ((pTI->TypeAttr.typekind == TKIND_DISPATCH) &&
+            (*pptfd)->funcdesc.elemdescFunc.tdesc.vt == VT_HRESULT)
+        {
+            if (pFuncRec->nrargs &&
+                ((*pptfd)->funcdesc.lprgelemdescParam[pFuncRec->nrargs - 1].u.paramdesc.wParamFlags & PARAMFLAG_FRETVAL))
             {
-                TYPEDESC* lpArgTypeDesc;
-
-                (*pptfd)->funcdesc.elemdescFunc =
-                (*pptfd)->funcdesc.lprgelemdescParam[j];
-
-                lpArgTypeDesc = & ((*pptfd)->funcdesc.elemdescFunc.tdesc) ;
-
-                while ( lpArgTypeDesc != NULL )
+                ELEMDESC *elemdesc = &(*pptfd)->funcdesc.lprgelemdescParam[pFuncRec->nrargs - 1];
+                if (elemdesc->tdesc.vt != VT_PTR)
                 {
-                    switch ( lpArgTypeDesc->vt )
-                    {
-                    case VT_PTR:
-                        lpArgTypeDesc = lpArgTypeDesc->u.lptdesc;
-                        break;
-                    case VT_CARRAY:
-                        lpArgTypeDesc =
-                        & (lpArgTypeDesc->u.lpadesc->tdescElem);
-
-                        break;
-
-                    case VT_USERDEFINED:
-                        MSFT_DoRefType(pcx,
-				       pTI,
-				       lpArgTypeDesc->u.hreftype);
-
-                        lpArgTypeDesc = NULL;
-                        break;
-
-                    default:
-                        lpArgTypeDesc = NULL;
-                    }
+                    ERR_(typelib)("elemdesc should have started with VT_PTR instead of:\n");
+                    if (ERR_ON(typelib))
+                        dump_ELEMDESC(elemdesc);
+                    /* FIXME: return error */
+                    break;
                 }
+ 
+                (*pptfd)->funcdesc.elemdescFunc = *elemdesc;
+ 
+                /* dereference parameter */
+                (*pptfd)->funcdesc.elemdescFunc.tdesc = *elemdesc->tdesc.u.lptdesc;
+ 
+                pFuncRec->nrargs--;
+                (*pptfd)->funcdesc.cParams = pFuncRec->nrargs;
             }
+            else
+                (*pptfd)->funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
+
         }
 
         /* scode is not used: archaic win16 stuff FIXME: right? */



More information about the wine-cvs mailing list