From 241336c7491e5ef214c78d39ef1fb380846614fe Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 16 Nov 2006 17:49:31 +0000 Subject: [PATCH] ole32: CoRegisterMessageFilter shouldn't crash on an uninitialized apartment. --- dlls/ole32/compobj.c | 4 ++-- dlls/ole32/tests/compobj.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index db76dbcebb5..59093ff4b28 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -2671,9 +2671,9 @@ HRESULT WINAPI CoRegisterMessageFilter( apt = COM_CurrentApt(); /* can't set a message filter in a multi-threaded apartment */ - if (apt->multi_threaded) + if (!apt || apt->multi_threaded) { - ERR("can't set message filter in MTA\n"); + WARN("can't set message filter in MTA or uninitialized apt\n"); return CO_E_NOT_SUPPORTED; } diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index b2e9bf9c6fa..81bf8310fa8 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -250,9 +250,10 @@ static void test_CoRegisterMessageFilter(void) HRESULT hr; IMessageFilter *prev_filter; -#if 0 /* crashes without an apartment! */ hr = CoRegisterMessageFilter(&MessageFilter, &prev_filter); -#endif + ok(hr == CO_E_NOT_SUPPORTED, + "CoRegisterMessageFilter should have failed with CO_E_NOT_SUPPORTED instead of 0x%08x\n", + hr); pCoInitializeEx(NULL, COINIT_MULTITHREADED); prev_filter = (IMessageFilter *)0xdeadbeef;