Hans Leidekker : shell32: Reject NULL path in IShellLink_SetPath.

Alexandre Julliard julliard at winehq.org
Wed Sep 9 09:57:23 CDT 2009


Module: wine
Branch: master
Commit: 6b107c7f62d568d8f1c026fad394f8897abd1523
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6b107c7f62d568d8f1c026fad394f8897abd1523

Author: Hans Leidekker <hans at meelstraat.net>
Date:   Wed Sep  9 12:25:44 2009 +0200

shell32: Reject NULL path in IShellLink_SetPath.

---

 dlls/shell32/shelllink.c       |    4 ++++
 dlls/shell32/tests/shelllink.c |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index 05978f3..231c72c 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -1651,6 +1651,8 @@ static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
 
     TRACE("(%p)->(path=%s)\n",This, pszFile);
 
+    if (!pszFile) return E_INVALIDARG;
+
     str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
     if( !str ) 
         return E_OUTOFMEMORY;
@@ -2168,6 +2170,8 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
 
     TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
 
+    if (!pszFile) return E_INVALIDARG;
+
     /* quotes at the ends of the string are stripped */
     len = lstrlenW(pszFile);
     if (pszFile[0] == '"' && pszFile[len-1] == '"')
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index c28c715..a1e1cd4 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -156,6 +156,9 @@ static void test_get_set(void)
     ok(SUCCEEDED(r), "GetPath failed (0x%08x)\n", r);
     ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
 
+    r = IShellLinkA_SetPath(sl, NULL);
+    ok(r==E_INVALIDARG, "SetPath failed (0x%08x)\n", r);
+
     r = IShellLinkA_SetPath(sl, "");
     ok(r==S_OK, "SetPath failed (0x%08x)\n", r);
 
@@ -700,6 +703,9 @@ static void test_datalink(void)
     ok( r == E_FAIL, "CopyDataBlock failed\n");
     ok( dar == NULL, "should be null\n");
 
+    r = IShellLinkW_SetPath(sl, NULL);
+    ok(r == E_INVALIDARG, "set path failed\n");
+
     r = IShellLinkW_SetPath(sl, lnk);
     ok(r == S_OK, "set path failed\n");
 




More information about the wine-cvs mailing list