[BROWSEUI] Don't call SHOpenFolderAndSelectItems with full pidls and don't leak them (#6153)

- The children passed to SHOpenFolderAndSelectItems are not supposed to be full pidls.
- Don't leak the array from IShellFolderView::GetSelectedObjects.
This commit is contained in:
Whindmar Saksit 2023-12-17 22:16:19 +01:00 committed by GitHub
parent 7ffc31554d
commit 5be53f553c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -809,11 +809,10 @@ class CFindFolderContextMenu :
CComHeapPtr<ITEMIDLIST> folderPidl(ILCreateFromPathW(_ILGetPath(apidl[i])));
if (!folderPidl)
return E_OUTOFMEMORY;
CComHeapPtr<ITEMIDLIST> filePidl(ILCombine(folderPidl, _ILGetFSPidl(apidl[i])));
if (!filePidl)
return E_OUTOFMEMORY;
SHOpenFolderAndSelectItems(folderPidl, 1, &filePidl, 0);
LPCITEMIDLIST child = _ILGetFSPidl(apidl[i]);
SHOpenFolderAndSelectItems(folderPidl, 1, &child, 0);
}
LocalFree(apidl); // Yes, LocalFree
return S_OK;
}