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