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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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

dde8fcfcbf518e10fa3ab9aec723f9fda05f0d12
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -1163,7 +1163,7 @@ HRESULT WINAPI IShellLink_Constructor( I
  if (!sl)
             return E_OUTOFMEMORY;
 
- sl->ref = 1;
+ sl->ref = 0; /* QueryInterface will AddRef */
  sl->lpVtbl = &slvt;
  sl->lpvtblw = &slvtw;
  sl->lpvtblPersistFile = &pfvt;
@@ -1176,18 +1176,7 @@ 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;
+        return ShellLink_QueryInterface( sl, riid, ppv );
 }
 
 


Reply | Threaded
Open this post in threaded view
|

Re: SHELL32: Use ShellLink_QueryInterface to return the right interface in IShellLink_Constructor.

Alexandre Julliard
Mike McCormack <[hidden email]> writes:

> @@ -1176,18 +1176,7 @@ 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;
> +        return ShellLink_QueryInterface( sl, riid, ppv );

This will leak the object if QueryInterface fails.

--
Alexandre Julliard
[hidden email]