Commit b560dbae authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32: Fully initialize VARIANT structure in VariantInit().

parent 7e67cc99
......@@ -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));
memset(&v2, 0, sizeof(v2));
memset(&v3, -1, sizeof(v3));
V_VT(&v3) = VT_EMPTY;
VariantInit(&v);
ok(V_VT(&v) == VT_EMPTY, "VariantInit() returned vt %d\n", V_VT(&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 */
......
......@@ -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);
/* 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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment