Commit f4890dac authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

atl: Avoid NULL pointer reference in AtlComModuleRegisterClassObjects().

parent 5739db59
...@@ -538,7 +538,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c ...@@ -538,7 +538,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c
return E_INVALIDARG; return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) { for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
if(!(*iter)->pfnGetClassObject) if(!(*iter) || !(*iter)->pfnGetClassObject)
continue; continue;
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk); hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
...@@ -566,7 +566,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c ...@@ -566,7 +566,7 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c
return E_INVALIDARG; return E_INVALIDARG;
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) { for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
if(!(*iter)->pfnGetClassObject) if(!(*iter) || !(*iter)->pfnGetClassObject)
continue; continue;
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk); hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
......
...@@ -1088,6 +1088,33 @@ static void test_AtlComModuleGetClassObject(void) ...@@ -1088,6 +1088,33 @@ static void test_AtlComModuleGetClassObject(void)
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr); ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
} }
static void test_AtlComModuleRegisterClassObjects(void)
{
_ATL_OBJMAP_ENTRY *null_entry = NULL;
_ATL_COM_MODULE module;
HRESULT hr;
/* Test NULL module */
hr = AtlComModuleRegisterClassObjects(NULL, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
/* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
module.cbSize = sizeof(module);
module.m_ppAutoObjMapFirst = NULL;
module.m_ppAutoObjMapLast = NULL;
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
todo_wine_if(hr == S_OK)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
/* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
module.cbSize = sizeof(module);
module.m_ppAutoObjMapFirst = &null_entry;
module.m_ppAutoObjMapLast = &null_entry;
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
todo_wine_if(hr == S_OK)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
}
START_TEST(atl) START_TEST(atl)
{ {
if (!register_class()) if (!register_class())
...@@ -1104,6 +1131,7 @@ START_TEST(atl) ...@@ -1104,6 +1131,7 @@ START_TEST(atl)
test_AtlAxAttachControl(); test_AtlAxAttachControl();
test_AtlAxCreateControl(); test_AtlAxCreateControl();
test_AtlComModuleGetClassObject(); test_AtlComModuleGetClassObject();
test_AtlComModuleRegisterClassObjects();
CoUninitialize(); CoUninitialize();
} }
...@@ -55,11 +55,39 @@ static void test_AtlComModuleGetClassObject(void) ...@@ -55,11 +55,39 @@ static void test_AtlComModuleGetClassObject(void)
ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr); ok(hr == CLASS_E_CLASSNOTAVAILABLE, "Unexpected hr %#lx.\n", hr);
} }
static void test_AtlComModuleRegisterClassObjects(void)
{
_ATL_OBJMAP_ENTRY_EX *null_entry = NULL;
_ATL_COM_MODULE module;
HRESULT hr;
/* Test NULL module */
hr = AtlComModuleRegisterClassObjects(NULL, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
/* Test NULL m_ppAutoObjMapFirst and m_ppAutoObjMapLast */
module.cbSize = sizeof(module);
module.m_ppAutoObjMapFirst = NULL;
module.m_ppAutoObjMapLast = NULL;
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
todo_wine_if(hr == S_OK)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
/* Test m_ppAutoObjMapFirst and m_ppAutoObjMapLast both pointing to a NULL entry */
module.cbSize = sizeof(module);
module.m_ppAutoObjMapFirst = &null_entry;
module.m_ppAutoObjMapLast = &null_entry;
hr = AtlComModuleRegisterClassObjects(&module, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
todo_wine_if(hr == S_OK)
ok(hr == S_FALSE, "Unexpected hr %#lx.\n", hr);
}
START_TEST(atl) START_TEST(atl)
{ {
CoInitialize(NULL); CoInitialize(NULL);
test_AtlComModuleGetClassObject(); test_AtlComModuleGetClassObject();
test_AtlComModuleRegisterClassObjects();
CoUninitialize(); CoUninitialize();
} }
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