oleaut32: Fix AddFuncDesc() to ignore scodes array length when NULL array pointer is passed.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-08-25 20:57:16 +03:00 committed by Alexandre Julliard
parent 5c4cbc9d60
commit 37745b093d
2 changed files with 6 additions and 2 deletions

View File

@ -2033,6 +2033,8 @@ static void test_CreateTypeLib(SYSKIND sys) {
funcdesc.lprgelemdescParam = NULL;
funcdesc.invkind = INVOKE_FUNC;
funcdesc.cParams = 0;
funcdesc.cScodes = 1;
funcdesc.lprgscode = NULL;
hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
ok(hres == S_OK, "got %08x\n", hres);

View File

@ -10431,11 +10431,13 @@ static HRESULT WINAPI ICreateTypeInfo2_fnAddFuncDesc(ICreateTypeInfo2 *iface,
if (tmp_func_desc.funcdesc.oVft != 0)
tmp_func_desc.funcdesc.oVft |= 1;
if (funcDesc->cScodes) {
if (funcDesc->cScodes && funcDesc->lprgscode) {
tmp_func_desc.funcdesc.lprgscode = heap_alloc(sizeof(SCODE) * funcDesc->cScodes);
memcpy(tmp_func_desc.funcdesc.lprgscode, funcDesc->lprgscode, sizeof(SCODE) * funcDesc->cScodes);
} else
} else {
tmp_func_desc.funcdesc.lprgscode = NULL;
tmp_func_desc.funcdesc.cScodes = 0;
}
buf_size = TLB_SizeElemDesc(&funcDesc->elemdescFunc);
for (i = 0; i < funcDesc->cParams; ++i) {