dxdiagn: Initialize output pointer to NULL in IDxDiagContainer::GetChildContainer.
This commit is contained in:
parent
fa9af5b68a
commit
c245c6ed09
|
@ -129,7 +129,7 @@ static HRESULT IDxDiagContainerImpl_GetChildContainerInternal(PDXDIAGCONTAINER i
|
||||||
|
|
||||||
static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
|
static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
|
||||||
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
|
||||||
IDxDiagContainer* pContainer = NULL;
|
IDxDiagContainer* pContainer = (PDXDIAGCONTAINER)This;
|
||||||
LPWSTR tmp, orig_tmp;
|
LPWSTR tmp, orig_tmp;
|
||||||
INT tmp_len;
|
INT tmp_len;
|
||||||
WCHAR* cur;
|
WCHAR* cur;
|
||||||
|
@ -141,7 +141,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER if
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
pContainer = (PDXDIAGCONTAINER) This;
|
*ppInstance = NULL;
|
||||||
|
|
||||||
tmp_len = strlenW(pwszContainer) + 1;
|
tmp_len = strlenW(pwszContainer) + 1;
|
||||||
orig_tmp = tmp = HeapAlloc(GetProcessHeap(), 0, tmp_len * sizeof(WCHAR));
|
orig_tmp = tmp = HeapAlloc(GetProcessHeap(), 0, tmp_len * sizeof(WCHAR));
|
||||||
|
|
|
@ -219,11 +219,82 @@ cleanup:
|
||||||
IDxDiagProvider_Release(pddp);
|
IDxDiagProvider_Release(pddp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_GetChildContainer(void)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
WCHAR container[256] = {0};
|
||||||
|
IDxDiagContainer *child;
|
||||||
|
|
||||||
|
if (!create_root_IDxDiagContainer())
|
||||||
|
{
|
||||||
|
skip("Unable to create the root IDxDiagContainer\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Test various combinations of invalid parameters. */
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, NULL, NULL);
|
||||||
|
ok(hr == E_INVALIDARG,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
child = (void*)0xdeadbeef;
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, NULL, &child);
|
||||||
|
ok(hr == E_INVALIDARG,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
|
||||||
|
ok(child == (void*)0xdeadbeef, "Expected output pointer to be unchanged, got %p\n", child);
|
||||||
|
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, container, NULL);
|
||||||
|
ok(hr == E_INVALIDARG,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
child = (void*)0xdeadbeef;
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
|
||||||
|
ok(hr == E_INVALIDARG,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr);
|
||||||
|
ok(child == NULL, "Expected output pointer to be NULL, got %p\n", child);
|
||||||
|
|
||||||
|
/* Get the name of a suitable child container. */
|
||||||
|
hr = IDxDiagContainer_EnumChildContainerNames(pddc, 0, container, sizeof(container)/sizeof(WCHAR));
|
||||||
|
ok(hr == S_OK,
|
||||||
|
"Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
skip("IDxDiagContainer::EnumChildContainerNames failed\n");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
child = (void*)0xdeadbeef;
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, container, &child);
|
||||||
|
ok(hr == S_OK,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
|
||||||
|
ok(child != NULL && child != (void*)0xdeadbeef, "Expected a valid output pointer, got %p\n", child);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
IDxDiagContainer *ptr;
|
||||||
|
|
||||||
|
/* Show that IDxDiagContainer::GetChildContainer returns a different pointer
|
||||||
|
* for multiple calls for the same container name. */
|
||||||
|
hr = IDxDiagContainer_GetChildContainer(pddc, container, &ptr);
|
||||||
|
ok(hr == S_OK,
|
||||||
|
"Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
todo_wine ok(ptr != child, "Expected the two pointers (%p vs. %p) to be unequal", child, ptr);
|
||||||
|
|
||||||
|
IDxDiagContainer_Release(ptr);
|
||||||
|
IDxDiagContainer_Release(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
IDxDiagContainer_Release(pddc);
|
||||||
|
IDxDiagProvider_Release(pddp);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(container)
|
START_TEST(container)
|
||||||
{
|
{
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
test_GetNumberOfChildContainers();
|
test_GetNumberOfChildContainers();
|
||||||
test_GetNumberOfProps();
|
test_GetNumberOfProps();
|
||||||
test_EnumChildContainerNames();
|
test_EnumChildContainerNames();
|
||||||
|
test_GetChildContainer();
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue