SHELL32: Use ShellLink_QueryInterface to return the right interface in IShellLink_Constructor. (RESEND)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

SHELL32: Use ShellLink_QueryInterface to return the right interface in IShellLink_Constructor. (RESEND)

Mike McCormack

This version fixes a memory leak spotted by Alexandre.

Mike


ChangeLog:
Use ShellLink_QueryInterface to return the right interface in
IShellLink_Constructor.


diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -1152,6 +1152,7 @@ HRESULT WINAPI IShellLink_Constructor( I
                REFIID riid, LPVOID *ppv )
 {
  IShellLinkImpl * sl;
+ HRESULT r;
 
  TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid));
 
@@ -1176,18 +1177,9 @@ HRESULT WINAPI IShellLink_Constructor( I
 
  TRACE("(%p)->()\n",sl);
 
- if (IsEqualIID(riid, &IID_IUnknown) ||
-    IsEqualIID(riid, &IID_IShellLinkA))
-    *ppv = sl;
- else if (IsEqualIID(riid, &IID_IShellLinkW))
-    *ppv = &(sl->lpvtblw);
- else {
-    LocalFree((HLOCAL)sl);
-    ERR("E_NOINTERFACE\n");
-    return E_NOINTERFACE;
- }
-
- return S_OK;
+        r = ShellLink_QueryInterface( sl, riid, ppv );
+        ShellLink_Release( sl );
+        return r;
 }