shell32: Zero-init the out parameter and fix the error if the folder id is invalid.

This commit is contained in:
Huw Davies 2012-02-08 16:52:16 +00:00 committed by Alexandre Julliard
parent 154aef98d8
commit 8272045cd8
2 changed files with 9 additions and 1 deletions

View File

@ -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;

View File

@ -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);