oleaut32: Return error if VT_HRESULT is used as return type in DispCallFunc.

This commit is contained in:
Jacek Caban 2013-02-12 14:52:30 +01:00 committed by Alexandre Julliard
parent 6b0e2c8fdf
commit 88367a3c58
2 changed files with 24 additions and 0 deletions

View File

@ -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 */

View File

@ -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;