Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/hlink/browse_ctx.c | 22 ++++++++++++++-------- dlls/hlink/tests/browse_ctx.c | 10 ++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/hlink/browse_ctx.c b/dlls/hlink/browse_ctx.c index 44db1a1fc0c..88ee3ea29af 100644 --- a/dlls/hlink/browse_ctx.c +++ b/dlls/hlink/browse_ctx.c @@ -53,14 +53,17 @@ static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IHlinkBrowseContext)) - *ppvObj = This; - - if (*ppvObj) { - IUnknown_AddRef((IUnknown*)(*ppvObj)); - return S_OK; + *ppvObj = &This->IHlinkBrowseContext_iface; } - return E_NOINTERFACE; + else + { + *ppvObj = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*ppvObj); + return S_OK; }
static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface) @@ -368,6 +371,7 @@ static const IHlinkBrowseContextVtbl hlvt = HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) { HlinkBCImpl * hl; + HRESULT hr;
TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid)); *ppv = NULL; @@ -383,6 +387,8 @@ HRESULT HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid, void ** hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt; list_init(&hl->links);
- *ppv = hl; - return S_OK; + hr = IHlinkBrowseContext_QueryInterface(&hl->IHlinkBrowseContext_iface, riid, ppv); + IHlinkBrowseContext_Release(&hl->IHlinkBrowseContext_iface); + + return hr; } diff --git a/dlls/hlink/tests/browse_ctx.c b/dlls/hlink/tests/browse_ctx.c index c0a731bb334..4bd7af9d42f 100644 --- a/dlls/hlink/tests/browse_ctx.c +++ b/dlls/hlink/tests/browse_ctx.c @@ -197,10 +197,20 @@ static void test_GetObject(void) IMoniker_Release(dummy); }
+static void test_interfaces(void) +{ + IHlinkBrowseContext *bc; + HRESULT hr; + + hr = HlinkCreateBrowseContext(NULL, &IID_IMoniker, (void **)&bc); + ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr); +} + START_TEST(browse_ctx) { CoInitialize(NULL);
+ test_interfaces(); test_SetInitialHlink(); test_BrowseWindowInfo(); test_GetObject();