oleaut32: Fully initialize VARIANT structure in VariantInit().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-08-24 16:13:05 +03:00 committed by Alexandre Julliard
parent 7e67cc996f
commit b560dbaebc
2 changed files with 12 additions and 18 deletions

View File

@ -673,11 +673,16 @@ static void _test_bstr_var(unsigned line, const VARIANT *v, const WCHAR *str)
static void test_VariantInit(void)
{
VARIANT v;
VARIANT v, v2, v3;
memset(&v, -1, sizeof(v));
VariantInit(&v);
ok(V_VT(&v) == VT_EMPTY, "VariantInit() returned vt %d\n", V_VT(&v));
memset(&v, -1, sizeof(v));
memset(&v2, 0, sizeof(v2));
memset(&v3, -1, sizeof(v3));
V_VT(&v3) = VT_EMPTY;
VariantInit(&v);
ok(!memcmp(&v, &v2, sizeof(v)) ||
broken(!memcmp(&v, &v3, sizeof(v3)) /* pre Win8 */), "Unexpected contents.\n");
}
/* All possible combinations of extra V_VT() flags */

View File

@ -545,24 +545,13 @@ static inline HRESULT VARIANT_ValidateType(VARTYPE vt)
/******************************************************************************
* VariantInit [OLEAUT32.8]
*
* Initialise a variant.
*
* PARAMS
* pVarg [O] Variant to initialise
*
* RETURNS
* Nothing.
*
* NOTES
* This function simply sets the type of the variant to VT_EMPTY. It does not
* free any existing value, use VariantClear() for that.
* Since Windows 8.1 whole structure is initialized, before that only type field was reset to VT_EMPTY.
*/
void WINAPI VariantInit(VARIANTARG* pVarg)
{
TRACE("(%p)\n", pVarg);
TRACE("(%p)\n", pVarg);
/* Win8.1 zeroes whole struct. Previous implementations don't set any other fields. */
V_VT(pVarg) = VT_EMPTY;
memset(pVarg, 0, sizeof(*pVarg));
}
HRESULT VARIANT_ClearInd(VARIANTARG *pVarg)