From: Qian Hong Subject: [PATCH] atl100: Fixed AtlAdvise and AtlUnadvise crashing with NULL pUnkCP. Message-Id: <51A0B50B.2010703@codeweavers.com> Date: Sat, 25 May 2013 20:56:43 +0800 Fixed QQ crashing. --- dlls/atl100/atl.c | 6 ++++++ dlls/atl100/tests/atl.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dlls/atl100/atl.c b/dlls/atl100/atl.c index d3278a5..383ad1c 100644 --- a/dlls/atl100/atl.c +++ b/dlls/atl100/atl.c @@ -51,6 +51,9 @@ HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw); + if(!pUnkCP) + return E_INVALIDARG; + hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container); if(FAILED(hres)) return hres; @@ -76,6 +79,9 @@ HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw) TRACE("%p %p %d\n", pUnkCP, iid, dw); + if(!pUnkCP) + return E_INVALIDARG; + hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container); if(FAILED(hres)) return hres; diff --git a/dlls/atl100/tests/atl.c b/dlls/atl100/tests/atl.c index 1304ac1..4cf4a62 100644 --- a/dlls/atl100/tests/atl.c +++ b/dlls/atl100/tests/atl.c @@ -359,6 +359,12 @@ static void test_cp(void) DWORD cookie = 0; HRESULT hres; + hres = AtlAdvise(NULL, (IUnknown*)0xdeed0000, &CLSID_Test, &cookie); + ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres); + + hres = AtlUnadvise(NULL, &CLSID_Test, 0xdeadbeef); + ok(hres == E_INVALIDARG, "expect E_INVALIDARG, returned %08x\n", hres); + hres = AtlAdvise((IUnknown*)&ConnectionPointContainer, (IUnknown*)0xdead0000, &CLSID_Test, &cookie); ok(hres == S_OK, "AtlAdvise failed: %08x\n", hres); ok(cookie == 0xdeadbeef, "cookie = %x\n", cookie);