shell32: Always NULL-terminate path in SHGetPathFromIDList.
This commit is contained in:
parent
4d3877b649
commit
961193bc5d
|
@ -1240,8 +1240,7 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
|
||||||
BOOL bSuccess;
|
BOOL bSuccess;
|
||||||
|
|
||||||
bSuccess = SHGetPathFromIDListW(pidl, wszPath);
|
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;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
@ -1262,6 +1261,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
|
||||||
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
|
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
|
||||||
pdump(pidl);
|
pdump(pidl);
|
||||||
|
|
||||||
|
*pszPath = '\0';
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -771,6 +771,13 @@ static void test_SHGetPathFromIDList(void)
|
||||||
|
|
||||||
if(!pSHGetSpecialFolderPathW) return;
|
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. */
|
/* Calling SHGetPathFromIDList with an empty pidl should return the desktop folder's path. */
|
||||||
result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE);
|
result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE);
|
||||||
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %08lx\n", GetLastError());
|
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %08lx\n", GetLastError());
|
||||||
|
@ -794,9 +801,12 @@ static void test_SHGetPathFromIDList(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
|
wszPath[0] = 'a';
|
||||||
|
wszPath[1] = '\0';
|
||||||
result = SHGetPathFromIDListW(pidlMyComputer, wszPath);
|
result = SHGetPathFromIDListW(pidlMyComputer, wszPath);
|
||||||
ok (!result, "SHGetPathFromIDList succeeded where it shouldn't!\n");
|
ok (!result, "SHGetPathFromIDList succeeded where it shouldn't!\n");
|
||||||
ok (GetLastError()==0xdeadbeef, "SHGetPathFromIDList shouldn't set last error! Last error: %08lx\n", GetLastError());
|
ok (GetLastError()==0xdeadbeef, "SHGetPathFromIDList shouldn't set last error! Last error: %08lx\n", GetLastError());
|
||||||
|
ok (!wszPath[0], "Expected empty path\n");
|
||||||
if (result) {
|
if (result) {
|
||||||
IShellFolder_Release(psfDesktop);
|
IShellFolder_Release(psfDesktop);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue