Commit bbdcccd3 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

oleaut32: Add validation of some more parameters in IFontDisp::Invoke.

parent 207ec43e
......@@ -1402,6 +1402,41 @@ static HRESULT WINAPI OLEFontImpl_Invoke(
OLEFontImpl *this = impl_from_IDispatch(iface);
HRESULT hr;
/* validate parameters */
if (!IsEqualIID(riid, &IID_NULL))
{
ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
return DISP_E_UNKNOWNINTERFACE;
}
if (wFlags & DISPATCH_PROPERTYGET)
{
if (!pVarResult)
{
ERR("null pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
return DISP_E_PARAMNOTOPTIONAL;
}
}
else if (wFlags & DISPATCH_PROPERTYPUT)
{
if (!pDispParams)
{
ERR("null pDispParams not allowed when DISPATCH_PROPERTYPUT specified\n");
return DISP_E_PARAMNOTOPTIONAL;
}
if (pDispParams->cArgs != 1)
{
ERR("param count for DISPATCH_PROPERTYPUT was %ld instead of 1\n", pDispParams->cArgs);
return DISP_E_BADPARAMCOUNT;
}
}
else
{
ERR("one of DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT must be specified\n");
return DISP_E_MEMBERNOTFOUND;
}
switch (dispIdMember) {
case DISPID_FONT_NAME:
if (wFlags & DISPATCH_PROPERTYGET) {
......
......@@ -425,6 +425,39 @@ void test_GetIDsOfNames(void)
DISPID_FONT_NAME, 0, S_OK,1);
}
static void test_Invoke(void)
{
IFontDisp *fontdisp;
HRESULT hr;
VARIANTARG vararg;
DISPPARAMS dispparams;
hr = pOleCreateFontIndirect(NULL, &IID_IFontDisp, (void **)&fontdisp);
ok_ole_success(hr, "OleCreateFontIndirect\n");
V_VT(&vararg) = VT_BOOL;
V_BOOL(&vararg) = FALSE;
dispparams.cNamedArgs = 0;
dispparams.rgdispidNamedArgs = NULL;
dispparams.cArgs = 1;
dispparams.rgvarg = &vararg;
hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_IFontDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
ok(hr == DISP_E_UNKNOWNINTERFACE, "IFontDisp_Invoke should have returned DISP_E_UNKNOWNINTERFACE instead of 0x%08lx\n", hr);
dispparams.cArgs = 0;
dispparams.rgvarg = NULL;
hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
ok(hr == DISP_E_BADPARAMCOUNT, "IFontDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr);
hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL);
ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr);
IFontDisp_Release(fontdisp);
}
START_TEST(olefont)
{
hOleaut32 = LoadLibraryA("oleaut32.dll");
......@@ -447,4 +480,5 @@ START_TEST(olefont)
test_font_events_disp();
test_GetIDsOfNames();
test_Invoke();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment