Module: wine Branch: master Commit: 8d18b8934618f2d1e7d1e3a009f8f04771e03a0d URL: http://source.winehq.org/git/wine.git/?a=commit;h=8d18b8934618f2d1e7d1e3a009...
Author: Qian Hong qhong@codeweavers.com Date: Sat May 25 20:56:43 2013 +0800
atl100: Fixed AtlAdvise and AtlUnadvise crashing with NULL pUnkCP.
---
dlls/atl100/atl.c | 6 ++++++ dlls/atl100/tests/atl.c | 6 ++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/dlls/atl100/atl.c b/dlls/atl100/atl.c index a8b8208..0aae80b 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);