From afdf040ea3d1202101439be7712508afa040042c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 26 Dec 2005 23:18:49 +0000 Subject: [PATCH] Sync to Wine-0_9_4: Robert Shearman - OLE: Fix SafeArrayCopy for NULL pvData. It is allowed to copy a SAFEARRAY with a NULL pvData, as long as cbElements is non-zero. Add a test for this and fix the safe array code. - OLE: Add const to several typelib functions. Add const attributes to parameters for several functions and fix up some formatting. - OleTranslateColor trace fix. OleTranslateColor isn't a stub so don't print ":stub" in the trace message. svn path=/trunk/; revision=20351 --- reactos/lib/oleaut32/oleaut.c | 2 +- reactos/lib/oleaut32/safearray.c | 10 +++++++++- reactos/lib/oleaut32/typelib.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/reactos/lib/oleaut32/oleaut.c b/reactos/lib/oleaut32/oleaut.c index 3ef2088e873..bedca34cde6 100644 --- a/reactos/lib/oleaut32/oleaut.c +++ b/reactos/lib/oleaut32/oleaut.c @@ -629,7 +629,7 @@ HRESULT WINAPI OleTranslateColor( COLORREF colorref; BYTE b = HIBYTE(HIWORD(clr)); - TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef); + TRACE("(%08lx, %p, %p)\n", clr, hpal, pColorRef); /* * In case pColorRef is NULL, provide our own to simplify the code. diff --git a/reactos/lib/oleaut32/safearray.c b/reactos/lib/oleaut32/safearray.c index b84226b322c..4ff056ab6a7 100644 --- a/reactos/lib/oleaut32/safearray.c +++ b/reactos/lib/oleaut32/safearray.c @@ -355,7 +355,9 @@ static HRESULT SAFEARRAY_DestroyData(SAFEARRAY *psa, ULONG ulStartCell) /* Copy data items from one array to another */ static HRESULT SAFEARRAY_CopyData(SAFEARRAY *psa, SAFEARRAY *dest) { - if (!psa->pvData || !dest->pvData || psa->fFeatures & FADF_DATADELETED) + if (!psa->pvData) + return S_OK; + else if (!dest->pvData || psa->fFeatures & FADF_DATADELETED) return E_INVALIDARG; else { @@ -1378,6 +1380,12 @@ HRESULT WINAPI SafeArrayCopy(SAFEARRAY *psa, SAFEARRAY **ppsaOut) if (!psa) return S_OK; /* Handles copying of NULL arrays */ + if (!psa->cbElements) + { + ERR("not copying an array of 0 elements\n"); + return E_INVALIDARG; + } + if (psa->fFeatures & (FADF_RECORD|FADF_HAVEIID|FADF_HAVEVARTYPE)) { VARTYPE vt; diff --git a/reactos/lib/oleaut32/typelib.c b/reactos/lib/oleaut32/typelib.c index a6e2495af18..29585a31d9d 100644 --- a/reactos/lib/oleaut32/typelib.c +++ b/reactos/lib/oleaut32/typelib.c @@ -85,7 +85,7 @@ WINE_DECLARE_DEBUG_CHANNEL(typelib); /* The OLE Automation ProxyStub Interface Class (aka Typelib Marshaler) */ const GUID CLSID_PSOAInterface = { 0x00020424, 0, 0, { 0xC0, 0, 0, 0, 0, 0, 0, 0x46 } }; -static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt); +static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt); static HRESULT TLB_AllocAndInitVarDesc(const VARDESC *src, VARDESC **dest_ptr); /**************************************************************************** @@ -5054,7 +5054,7 @@ _copy_arg( ITypeInfo2 *tinfo, TYPEDESC *tdesc, return E_FAIL; } -static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt) +static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt) { HRESULT hr = S_OK; ITypeInfo *tinfo2 = NULL; @@ -5088,11 +5088,11 @@ static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTY break; case TKIND_INTERFACE: - if (IsEqualIID(&IID_IDispatch, &tattr->guid)) - *vt |= VT_DISPATCH; - else - *vt |= VT_UNKNOWN; - break; + if (IsEqualIID(&IID_IDispatch, &tattr->guid)) + *vt |= VT_DISPATCH; + else + *vt |= VT_UNKNOWN; + break; case TKIND_DISPATCH: *vt |= VT_DISPATCH; @@ -5118,7 +5118,7 @@ static HRESULT userdefined_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTY return hr; } -static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYPE *vt) +static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, const TYPEDESC *tdesc, VARTYPE *vt) { HRESULT hr = S_OK; @@ -5134,7 +5134,7 @@ static HRESULT typedescvt_to_variantvt(ITypeInfo *tinfo, TYPEDESC *tdesc, VARTYP ((tdesc->vt == VT_PTR) && (tdesc->u.lptdesc->vt == VT_USERDEFINED))) { VARTYPE vt_userdefined = 0; - TYPEDESC *tdesc_userdefined = tdesc; + const TYPEDESC *tdesc_userdefined = tdesc; if (tdesc->vt == VT_PTR) { vt_userdefined = VT_BYREF;