Juan Lang : shell32: Always NULL-terminate path in
SHGetPathFromIDList.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jul 11 11:03:12 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 961193bc5ddcfe7b6419d32e62f55d9d47f62f2e
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=961193bc5ddcfe7b6419d32e62f55d9d47f62f2e
Author: Juan Lang <juan_lang at yahoo.com>
Date: Mon Jul 10 20:11:09 2006 -0700
shell32: Always NULL-terminate path in SHGetPathFromIDList.
---
dlls/shell32/pidl.c | 4 ++--
dlls/shell32/tests/shlfolder.c | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
index e4fe443..c849643 100644
--- a/dlls/shell32/pidl.c
+++ b/dlls/shell32/pidl.c
@@ -1240,8 +1240,7 @@ BOOL WINAPI SHGetPathFromIDListA(LPCITEM
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(LPCITEM
TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
pdump(pidl);
+ *pszPath = '\0';
if (!pidl)
return FALSE;
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 7a79ab6..7751514 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -771,6 +771,13 @@ static void test_SHGetPathFromIDList(voi
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(voi
}
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;
More information about the wine-cvs
mailing list