Nikolay Sivov : hlink: Return requested interface when creating IHlinkBrowseContext instance.

Alexandre Julliard julliard at winehq.org
Mon Apr 11 15:54:59 CDT 2022


Module: wine
Branch: master
Commit: 759e2eff8bada2d62d7001bb119917ee31c071c2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=759e2eff8bada2d62d7001bb119917ee31c071c2

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Apr 11 11:40:30 2022 +0300

hlink: Return requested interface when creating IHlinkBrowseContext instance.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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();




More information about the wine-cvs mailing list