oleaut32: Ensure that the right interface is passed to the callee in ITypeInfo::Invoke.

This commit is contained in:
Jacek Caban 2012-08-20 17:42:40 +02:00 committed by Alexandre Julliard
parent c74d9a43b8
commit 44936abd84
2 changed files with 33 additions and 1 deletions

View File

@ -782,7 +782,6 @@ static HRESULT WINAPI StaticWidget_Invoke(IStaticWidget *iface, DISPID dispIdMem
static HRESULT WINAPI StaticWidget_TestDual(IStaticWidget *iface, ItestDual *p)
{
trace("TestDual()\n");
todo_wine
ok(p == &TestDual, "wrong ItestDual\n");
return S_OK;
}

View File

@ -6357,6 +6357,7 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
for (i = 0; i < func_desc->cParams; i++)
{
USHORT wParamFlags = func_desc->lprgelemdescParam[i].u.paramdesc.wParamFlags;
TYPEDESC *tdesc = &func_desc->lprgelemdescParam[i].tdesc;
VARIANTARG *src_arg;
if (wParamFlags & PARAMFLAG_FLCID)
@ -6509,6 +6510,38 @@ static HRESULT WINAPI ITypeInfo_fnInvoke(
{
prgpvarg[i] = src_arg;
}
if((tdesc->vt == VT_USERDEFINED || (tdesc->vt == VT_PTR && tdesc->u.lptdesc->vt == VT_USERDEFINED))
&& (V_VT(prgpvarg[i]) == VT_DISPATCH || V_VT(prgpvarg[i]) == VT_UNKNOWN)) {
const TYPEDESC *userdefined_tdesc = tdesc;
IUnknown *userdefined_iface;
ITypeInfo *tinfo2;
TYPEATTR *tattr;
if(tdesc->vt == VT_PTR)
userdefined_tdesc = tdesc->u.lptdesc;
hres = ITypeInfo2_GetRefTypeInfo(iface, userdefined_tdesc->u.hreftype, &tinfo2);
if(FAILED(hres))
break;
hres = ITypeInfo_GetTypeAttr(tinfo2, &tattr);
if(FAILED(hres)) {
ITypeInfo_Release(tinfo2);
return hres;
}
hres = IUnknown_QueryInterface(V_UNKNOWN(prgpvarg[i]), &tattr->guid, (void**)&userdefined_iface);
ITypeInfo_ReleaseTypeAttr(tinfo2, tattr);
ITypeInfo_Release(tinfo2);
if(FAILED(hres)) {
ERR("argument does not support %s interface\n", debugstr_guid(&tattr->guid));
break;
}
IUnknown_Release(V_UNKNOWN(prgpvarg[i]));
V_UNKNOWN(prgpvarg[i]) = userdefined_iface;
}
}
else if (wParamFlags & PARAMFLAG_FOPT)
{