Module: wine Branch: master Commit: 8272045cd84c304c07ccc4273f1cd544cd20b209 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8272045cd84c304c07ccc4273f...
Author: Huw Davies huw@codeweavers.com Date: Wed Feb 8 16:52:16 2012 +0000
shell32: Zero-init the out parameter and fix the error if the folder id is invalid.
---
dlls/shell32/shellpath.c | 4 +++- dlls/shell32/tests/shellpath.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 8d1c70b..8c66646 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -3041,8 +3041,10 @@ HRESULT WINAPI SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, DWORD flags, HANDLE t
TRACE("%s, 0x%08x, %p, %p\n", debugstr_guid(rfid), flags, token, path);
+ *path = NULL; + if (index < 0) - return E_INVALIDARG; + return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );
if (flags & KF_FLAG_CREATE) index |= CSIDL_FLAG_CREATE; diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 91e9f35..1798ada 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -860,6 +860,12 @@ if (0) { /* crashes */ hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, NULL); ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got 0x%08x\n", hr); } + /* non-existent folder id */ + path = (void *)0xdeadbeef; + hr = pSHGetKnownFolderPath(&IID_IOleObject, 0, NULL, &path); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); + ok(path == NULL, "got %p\n", path); + path = NULL; hr = pSHGetKnownFolderPath(&FOLDERID_Desktop, 0, NULL, &path); ok(hr == S_OK, "expected S_OK, got 0x%08x\n", hr);