From 89b2cde891e6316cd1bef7c4c28396a575f4aced Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Fri, 4 Dec 2009 17:15:11 -0800 Subject: [PATCH] oleaut32: Report the parameter index for any failure in DispGetParam. --- dlls/oleaut32/dispatch.c | 36 +++++++++++++++++++++++----------- dlls/oleaut32/tests/dispatch.c | 27 ++++++------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/dlls/oleaut32/dispatch.c b/dlls/oleaut32/dispatch.c index 5d96bfb604..ed3fad4701 100644 --- a/dlls/oleaut32/dispatch.c +++ b/dlls/oleaut32/dispatch.c @@ -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; poscNamedArgs; 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; } @@ -241,8 +255,8 @@ static HRESULT WINAPI StdDispatch_QueryInterface( IsEqualIID(riid, &IID_IUnknown)) { *ppvObject = This; - IUnknown_AddRef((LPUNKNOWN)*ppvObject); - return S_OK; + IUnknown_AddRef((LPUNKNOWN)*ppvObject); + return S_OK; } return E_NOINTERFACE; } diff --git a/dlls/oleaut32/tests/dispatch.c b/dlls/oleaut32/tests/dispatch.c index fb1e31096d..c81210f5e5 100644 --- a/dlls/oleaut32/tests/dispatch.c +++ b/dlls/oleaut32/tests/dispatch.c @@ -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(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); - } + 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); - } + 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); - } + 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); - } + ok(err_index == 0, "Expected 0, got %d\n", err_index); CLEAR_VARARG(vararg); -- 2.32.0.93.g670b81a890