Commit 961193bc authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

shell32: Always NULL-terminate path in SHGetPathFromIDList.

parent 4d3877b6
......@@ -1240,8 +1240,7 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
BOOL bSuccess;
bSuccess = SHGetPathFromIDListW(pidl, wszPath);
if (bSuccess)
WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL);
WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL);
return bSuccess;
}
......@@ -1262,6 +1261,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
pdump(pidl);
*pszPath = '\0';
if (!pidl)
return FALSE;
......
......@@ -771,6 +771,13 @@ static void test_SHGetPathFromIDList(void)
if(!pSHGetSpecialFolderPathW) return;
/* Calling SHGetPathFromIDList with no pidl should return the empty string */
wszPath[0] = 'a';
wszPath[1] = '\0';
result = SHGetPathFromIDListW(NULL, wszPath);
ok(!result, "Expected failure\n");
ok(!wszPath[0], "Expected empty string\n");
/* Calling SHGetPathFromIDList with an empty pidl should return the desktop folder's path. */
result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE);
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %08lx\n", GetLastError());
......@@ -794,9 +801,12 @@ static void test_SHGetPathFromIDList(void)
}
SetLastError(0xdeadbeef);
wszPath[0] = 'a';
wszPath[1] = '\0';
result = SHGetPathFromIDListW(pidlMyComputer, wszPath);
ok (!result, "SHGetPathFromIDList succeeded where it shouldn't!\n");
ok (GetLastError()==0xdeadbeef, "SHGetPathFromIDList shouldn't set last error! Last error: %08lx\n", GetLastError());
ok (!wszPath[0], "Expected empty path\n");
if (result) {
IShellFolder_Release(psfDesktop);
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment