ole: Make the CoCreateInstance test succeed.

Move the uninitialized apartment check after zeroing out the return
value.
oldstable
Robert Shearman 2006-02-22 16:26:25 +00:00 committed by Alexandre Julliard
parent 8f6ba475e8
commit 6c529a7273
2 changed files with 6 additions and 8 deletions

View File

@ -1836,12 +1836,6 @@ HRESULT WINAPI CoCreateInstance(
TRACE("(rclsid=%s, pUnkOuter=%p, dwClsContext=%08lx, riid=%s, ppv=%p)\n", debugstr_guid(rclsid),
pUnkOuter, dwClsContext, debugstr_guid(iid), ppv);
if (!COM_CurrentApt())
{
ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED;
}
/*
* Sanity check
*/
@ -1853,6 +1847,12 @@ HRESULT WINAPI CoCreateInstance(
*/
*ppv = 0;
if (!COM_CurrentApt())
{
ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED;
}
/*
* The Standard Global Interface Table (GIT) object is a process-wide singleton.
* Rather than create a class factory, we can just check for it here

View File

@ -88,9 +88,7 @@ static void test_CoCreateInstance(void)
IUnknown *pUnk = (IUnknown *)0xdeadbeef;
HRESULT hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk);
ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have return CO_E_NOTINITIALIZED instead of 0x%08lx", hr);
todo_wine {
ok(pUnk == NULL, "CoCreateInstance should have changed the passed in pointer to NULL, instead of %p\n", pUnk);
}
OleInitialize(NULL);
hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk);