dxdiagn: Unconditionally initialize the passed variant in IDxDiagContainer::GetProp.
This commit is contained in:
parent
d54f4fc3c8
commit
9d7d35c1ee
|
@ -222,10 +222,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWS
|
|||
LIST_FOR_EACH_ENTRY(p, &This->cont->properties, IDxDiagContainerImpl_Property, entry)
|
||||
{
|
||||
if (0 == lstrcmpW(p->propName, pwszPropName)) {
|
||||
HRESULT hr = VariantClear(pvarProp);
|
||||
if (hr == DISP_E_ARRAYISLOCKED || hr == DISP_E_BADVARTYPE)
|
||||
VariantInit(pvarProp);
|
||||
|
||||
VariantInit(pvarProp);
|
||||
return VariantCopy(pvarProp, &p->vProp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,6 +568,7 @@ static void test_GetProp(void)
|
|||
VARIANT var;
|
||||
SAFEARRAY *sa;
|
||||
SAFEARRAYBOUND bound;
|
||||
ULONG ref;
|
||||
static const WCHAR emptyW[] = {0};
|
||||
static const WCHAR testW[] = {'t','e','s','t',0};
|
||||
|
||||
|
@ -680,8 +681,21 @@ static void test_GetProp(void)
|
|||
ok(hr == S_OK, "Expected SafeArrayUnlock to return S_OK, got 0x%08x\n", hr);
|
||||
hr = SafeArrayDestroy(sa);
|
||||
ok(hr == S_OK, "Expected SafeArrayDestroy to return S_OK, got 0x%08x\n", hr);
|
||||
IDxDiagContainer_Release(child);
|
||||
|
||||
/* Determine whether GetProp calls VariantClear on the passed variant. */
|
||||
V_VT(&var) = VT_UNKNOWN;
|
||||
V_UNKNOWN(&var) = (IUnknown *)child;
|
||||
IDxDiagContainer_AddRef(child);
|
||||
|
||||
hr = IDxDiagContainer_GetProp(child, property, &var);
|
||||
ok(hr == S_OK, "Expected IDxDiagContainer::GetProp to return S_OK, got 0x%08x\n", hr);
|
||||
ok(V_VT(&var) != VT_UNKNOWN, "Expected the variant to be modified\n");
|
||||
|
||||
IDxDiagContainer_AddRef(child);
|
||||
ref = IDxDiagContainer_Release(child);
|
||||
ok(ref == 2, "Expected reference count to be 2, got %u\n", ref);
|
||||
|
||||
IDxDiagContainer_Release(child);
|
||||
cleanup:
|
||||
IDxDiagContainer_Release(pddc);
|
||||
IDxDiagProvider_Release(pddp);
|
||||
|
|
Loading…
Reference in New Issue