From a796b8a3f7a7776876ea16cc9613a537c60a4fcb Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Fri, 23 Jun 2006 15:21:02 +0200 Subject: [PATCH] shlwapi: PathCombineW should return NULL on invalid parameters. --- dlls/shlwapi/path.c | 2 +- dlls/shlwapi/tests/path.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index cc134b2491f..5e9bd68f1f4 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -163,7 +163,7 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) TRACE("(%p,%s,%s)\n", lpszDest, debugstr_w(lpszDir), debugstr_w(lpszFile)); if (!lpszDest || (!lpszDir && !lpszFile)) - return lpszDest; /* Invalid parameters */ + return NULL; /* Invalid parameters */ if (!lpszFile || !*lpszFile) { diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c index 043e8992d34..168671e2315 100644 --- a/dlls/shlwapi/tests/path.c +++ b/dlls/shlwapi/tests/path.c @@ -31,6 +31,7 @@ static HMODULE hShlwapi; static HRESULT (WINAPI *pPathIsValidCharA)(char,DWORD); static HRESULT (WINAPI *pPathIsValidCharW)(WCHAR,DWORD); +static LPWSTR (WINAPI *pPathCombineW)(LPWSTR, LPCWSTR, LPCWSTR); const char* TEST_URL_1 = "http://www.winehq.org/tests?date=10/10/1923"; const char* TEST_URL_2 = "http://localhost:8080/tests%2e.html?date=Mon%2010/10/1923"; @@ -860,6 +861,37 @@ static void test_PathMatchSpec(void) ok (PathMatchSpecA(file, spec13) == TRUE, "PathMatchSpec: Spec13 failed\n"); } +static void test_PathCombine(void) +{ + LPSTR szString, szString2; + LPWSTR wszString, wszString2; + + szString2 = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(char)); + wszString2 = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); + + /* NULL test */ + szString = PathCombineA(NULL, NULL, NULL); + ok (szString == NULL, "Expected a NULL return\n"); + + if (pPathCombineW) + { + wszString = pPathCombineW(NULL, NULL, NULL); + ok (wszString == NULL, "Expected a NULL return\n"); + } + + /* Some NULL */ + szString = PathCombineA(szString2, NULL, NULL); + ok (szString == NULL, "Expected a NULL return\n"); + + if (pPathCombineW) + { + wszString = pPathCombineW(wszString2, NULL, NULL); + ok (wszString == NULL, "Expected a NULL return\n"); + } + + HeapFree(GetProcessHeap(), 0, szString2); + HeapFree(GetProcessHeap(), 0, wszString2); +} START_TEST(path) { @@ -893,4 +925,7 @@ START_TEST(path) pPathIsValidCharW = (void*)GetProcAddress(hShlwapi, (LPSTR)456); if (pPathIsValidCharW) test_PathIsValidCharW(); } + + pPathCombineW = (void*)GetProcAddress(hShlwapi, "PathCombineW"); + test_PathCombine(); } -- 2.11.4.GIT