Module: wine Branch: refs/heads/master Commit: 1be2e1edef9440a947c03ddc73a72fab64f3858d URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=1be2e1edef9440a947c03ddc...
Author: Eric Pouech eric.pouech@wanadoo.fr Date: Wed Feb 22 12:04:02 2006 +0100
shell32: Fixes for bugs found by valgrind on shell32 tests harness. - read strings from left to right (PathGetDriveNumberW) - don't access buffers before they are filled (SHGetPathFromIDListW) - fill buffers & variables on all paths (SHELL_FindExecutable) - handle error condition (unix_fs) - don't shoot in the blind for AW APIs (tests/shelllink.c)
---
dlls/shell32/pidl.c | 2 +- dlls/shell32/shfldr_unixfs.c | 3 ++- dlls/shell32/shlexec.c | 5 +++++ dlls/shell32/tests/shelllink.c | 15 ++++++++------- dlls/shlwapi/path.c | 9 ++++++--- 5 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c index 6ec496f..a3f9574 100644 --- a/dlls/shell32/pidl.c +++ b/dlls/shell32/pidl.c @@ -1259,7 +1259,7 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEM DWORD dwAttributes; STRRET strret;
- TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath)); + TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath); pdump(pidl);
if (!pidl) diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c index c0d7f87..7780adc 100644 --- a/dlls/shell32/shfldr_unixfs.c +++ b/dlls/shell32/shfldr_unixfs.c @@ -701,6 +701,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFold
if (!pNextPathElement) { SHFree(*ppidl); + *ppidl = NULL; return FALSE; } pidl = ILGetNext(pidl); @@ -1753,7 +1754,7 @@ static HRESULT WINAPI UnixFolder_ISFHelp ILFree(pidlRelative); SHChangeNotify(SHCNE_MKDIR, SHCNF_IDLIST, pidlAbsolute, NULL); ILFree(pidlAbsolute); - } + } else return E_FAIL; return S_OK; } } diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 14739d6..f5b1e88 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -597,6 +597,11 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath filetype[filetypelen] = '\0'; TRACE("File type: %s\n", debugstr_w(filetype)); } + else + { + *filetype = '\0'; + filetypelen = 0; + } }
if (*filetype) diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index 7d45ef3..384d914 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -43,23 +43,24 @@ static const WCHAR notafile[]= { 'C',':' * SHSimpleIDListFromPathA does not work on NT4. But if we call both we * get what we want on all platforms. */ -static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathA)(LPCSTR)=NULL; +static LPITEMIDLIST (WINAPI *pSHSimpleIDListFromPathAW)(LPCVOID);
static LPITEMIDLIST path_to_pidl(const char* path) { LPITEMIDLIST pidl;
- if (!pSHSimpleIDListFromPathA) + if (!pSHSimpleIDListFromPathAW) { HMODULE hdll=LoadLibraryA("shell32.dll"); - pSHSimpleIDListFromPathA=(void*)GetProcAddress(hdll, (char*)162); - if (!pSHSimpleIDListFromPathA) - trace("SHSimpleIDListFromPathA not found in shell32.dll\n"); + pSHSimpleIDListFromPathAW=(void*)GetProcAddress(hdll, (char*)162); + if (!pSHSimpleIDListFromPathAW) + trace("SHSimpleIDListFromPathAW not found in shell32.dll\n"); }
pidl=NULL; - if (pSHSimpleIDListFromPathA) - pidl=pSHSimpleIDListFromPathA(path); + /* pSHSimpleIDListFromPathAW maps to A on non NT platforms */ + if (pSHSimpleIDListFromPathAW && (GetVersion() & 0x80000000)) + pidl=pSHSimpleIDListFromPathAW(path);
if (!pidl) { diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c index 93c7fe8..bf9abf9 100644 --- a/dlls/shlwapi/path.c +++ b/dlls/shlwapi/path.c @@ -506,9 +506,12 @@ int WINAPI PathGetDriveNumberW(LPCWSTR l { TRACE ("(%s)\n",debugstr_w(lpszPath));
- if (lpszPath && lpszPath[1] == ':' && - tolowerW(*lpszPath) >= 'a' && tolowerW(*lpszPath) <= 'z') - return tolowerW(*lpszPath) - 'a'; + if (lpszPath) + { + WCHAR tl = tolowerW(lpszPath[0]); + if (tl >= 'a' && tl <= 'z' && lpszPath[1] == ':') + return tl - 'a'; + } return -1; }