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

This commit is contained in:
Huw Davies 2006-11-16 17:49:31 +00:00 committed by Alexandre Julliard
parent 7c70f7f9b2
commit 241336c749
2 changed files with 5 additions and 4 deletions

View File

@ -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;
}

View File

@ -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;