Commit 69e10bf1 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ole32: Add validation of parameters to CoGetClassObject and make sure to initialise ppv to NULL.

parent 932a2a0d
......@@ -1618,6 +1618,17 @@ HRESULT WINAPI CoGetClassObject(
TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
if (!ppv)
return E_INVALIDARG;
*ppv = NULL;
if (!COM_CurrentApt())
{
ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED;
}
if (pServerInfo) {
FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
......
......@@ -100,6 +100,17 @@ static void test_CoCreateInstance(void)
ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr);
}
static void test_CoGetClassObject(void)
{
IUnknown *pUnk = (IUnknown *)0xdeadbeef;
HRESULT hr = CoGetClassObject(&CLSID_MyComputer, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
ok(hr == CO_E_NOTINITIALIZED, "CoGetClassObject should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr);
ok(pUnk == NULL, "CoGetClassObject should have changed the passed in pointer to NULL, instead of %p\n", pUnk);
hr = CoGetClassObject(&CLSID_MyComputer, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, NULL);
ok(hr == E_INVALIDARG, "CoGetClassObject should have returned E_INVALIDARG instead of 0x%08lx\n", hr);
}
static ATOM register_dummy_class(void)
{
WNDCLASS wc =
......@@ -138,4 +149,5 @@ START_TEST(compobj)
test_CLSIDFromString();
test_CoCreateInstance();
test_ole_menu();
test_CoGetClassObject();
}
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