From 88367a3c58df9993164124c3abd558d6e4ffb12c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 12 Feb 2013 14:52:30 +0100 Subject: [PATCH] oleaut32: Return error if VT_HRESULT is used as return type in DispCallFunc. --- dlls/oleaut32/tests/typelib.c | 16 ++++++++++++++++ dlls/oleaut32/typelib.c | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 1bcc58400a5..077c59c9c54 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -923,6 +923,11 @@ static int WINAPI inst_func( void *inst, int a ) return a * 2; } +static HRESULT WINAPI ret_false_func(void) +{ + return S_FALSE; +} + static const void *vtable[] = { NULL, NULL, NULL, inst_func }; static void test_DispCallFunc(void) @@ -1038,6 +1043,17 @@ static void test_DispCallFunc(void) ok( res == S_OK, "DispCallFunc failed %x\n", res ); ok( V_VT(&result) == VT_I4, "wrong result type %d\n", V_VT(&result) ); ok( V_I4(&result) == 6, "wrong result %08x\n", V_I4(&result) ); + + memset( &result, 0xcc, sizeof(result) ); + res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_ERROR, 0, NULL, NULL, &result); + ok(res == S_OK, "DispCallFunc failed: %08x\n", res); + ok(V_VT(&result) == VT_ERROR, "V_VT(result) = %u\n", V_VT(&result)); + ok(V_ERROR(&result) == S_FALSE, "V_ERROR(result) = %08x\n", V_ERROR(&result)); + + memset( &result, 0xcc, sizeof(result) ); + res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_HRESULT, 0, NULL, NULL, &result); + ok(res == E_INVALIDARG, "DispCallFunc failed: %08x\n", res); + ok(V_VT(&result) == 0xcccc, "V_VT(result) = %u\n", V_VT(&result)); } /* RegDeleteTreeW from dlls/advapi32/registry.c */ diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 97f07d2beaf..0f3ca6b3962 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -6185,6 +6185,10 @@ DispCallFunc( case VT_CY: V_UI8(pvargResult) = call_method( func, argspos - 1, args + 1, &stack_offset ); break; + case VT_HRESULT: + WARN("invalid return type %u\n", vtReturn); + heap_free( args ); + return E_INVALIDARG; default: V_UI4(pvargResult) = call_method( func, argspos - 1, args + 1, &stack_offset ); break; @@ -6263,6 +6267,10 @@ DispCallFunc( args[0] = (DWORD_PTR)pvargResult; /* arg 0 is a pointer to the result */ call_method( func, argspos, args ); break; + case VT_HRESULT: + WARN("invalid return type %u\n", vtReturn); + heap_free( args ); + return E_INVALIDARG; default: V_UI8(pvargResult) = call_method( func, argspos - 1, args + 1 ); break;