Commit 89b2cde8 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

oleaut32: Report the parameter index for any failure in DispGetParam.

parent 02dcc198
......@@ -131,16 +131,13 @@ HRESULT WINAPI DispGetParam(
TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
position, pdispparams->cArgs, pdispparams->cNamedArgs);
if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
return E_INVALIDARG;
if (!pvarResult)
return E_INVALIDARG;
if (position < pdispparams->cArgs) {
if (position < pdispparams->cArgs)
{
/* positional arg? */
pos = pdispparams->cArgs - position - 1;
} else {
}
else
{
/* FIXME: is this how to handle named args? */
for (pos=0; pos<pdispparams->cNamedArgs; pos++)
if (pdispparams->rgdispidNamedArgs[pos] == position) break;
......@@ -148,10 +145,27 @@ HRESULT WINAPI DispGetParam(
if (pos==pdispparams->cNamedArgs)
return DISP_E_PARAMNOTFOUND;
}
if (pdispparams->cArgs > 0 && !pdispparams->rgvarg)
{
hr = E_INVALIDARG;
goto done;
}
if (!pvarResult)
{
hr = E_INVALIDARG;
goto done;
}
hr = VariantChangeType(pvarResult,
&pdispparams->rgvarg[pos],
0, vtTarg);
if (hr == DISP_E_TYPEMISMATCH) *puArgErr = pos;
done:
if (FAILED(hr))
*puArgErr = pos;
return hr;
}
......
......@@ -103,11 +103,8 @@ void test_DispGetParam(void)
INIT_DISPPARAMS(dispparams, NULL, NULL, 0, 0);
err_index = 0xdeadbeef;
hr = DispGetParam(&dispparams, 0, VT_I2, NULL, &err_index);
todo_wine
{
ok(hr == DISP_E_PARAMNOTFOUND,
"Expected DISP_E_PARAMNOTFOUND, got %08x\n", hr);
}
ok(err_index == 0xdeadbeef,
"Expected err_index to be unchanged, got %d\n", err_index);
......@@ -128,10 +125,7 @@ void test_DispGetParam(void)
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
/* pdispparams.cNamedArgs is 1, yet pdispparams.rgdispidNamedArgs is NULL.
*
......@@ -195,10 +189,7 @@ void test_DispGetParam(void)
err_index = 0xdeadbeef;
hr = DispGetParam(&dispparams, 2, VT_I2, NULL, &err_index);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
/* puArgErr is NULL. */
INIT_DISPPARAMS(dispparams, vararg, NULL, 3, 0);
......@@ -239,10 +230,7 @@ void test_DispGetParam(void)
ok(hr == DISP_E_OVERFLOW, "Expected DISP_E_OVERFLOW, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 1, "Expected 1, got %d\n", err_index);
}
/* Coerce the third (VT_BSTR) param to VT_I2. */
INIT_DISPPARAMS(dispparams, vararg, NULL, 3, 0);
......@@ -263,10 +251,7 @@ void test_DispGetParam(void)
ok(hr == DISP_E_BADVARTYPE, "Expected DISP_E_BADVARTYPE, got %08x\n", hr);
ok(V_VT(&result) == VT_EMPTY,
"Expected VT_EMPTY, got %08x\n", V_VT(&result));
todo_wine
{
ok(err_index == 0, "Expected 0, got %d\n", err_index);
}
CLEAR_VARARG(vararg);
......
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