From 6c529a72737fdf54eac63faaedd36d46e720d06d Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 22 Feb 2006 16:26:25 +0000 Subject: [PATCH] ole: Make the CoCreateInstance test succeed. Move the uninitialized apartment check after zeroing out the return value. --- dlls/ole32/compobj.c | 12 ++++++------ dlls/ole32/tests/compobj.c | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index a757adbf6db..67c865570dd 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -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 diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 8882d28fe3f..f1f97cf2ddc 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -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); -- 2.11.4.GIT