Commit 241336c7 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: CoRegisterMessageFilter shouldn't crash on an uninitialized apartment.

parent 7c70f7f9
......@@ -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;
}
......
......@@ -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;
......
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