From 8272045cd84c304c07ccc4273f1cd544cd20b209 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 8 Feb 2012 16:52:16 +0000 Subject: [PATCH] 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 deletion(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 8d1c70ba5ba..8c66646596d 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 91e9f35fde4..1798ada124a 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); -- 2.11.4.GIT