From 6d6bc885cb441f7d33f32170475131f37ffb4b30 Mon Sep 17 00:00:00 2001 From: Brock Mammen Date: Sat, 3 Aug 2019 11:58:49 -0500 Subject: [PATCH] [SHELLFIND] Use smart pointers for PIDLs --- dll/win32/browseui/shellfind/CFindFolder.cpp | 15 +++++++++------ dll/win32/browseui/shellfind/CSearchBar.cpp | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dll/win32/browseui/shellfind/CFindFolder.cpp b/dll/win32/browseui/shellfind/CFindFolder.cpp index cfb47cfa7b1..4e986bebeb1 100644 --- a/dll/win32/browseui/shellfind/CFindFolder.cpp +++ b/dll/win32/browseui/shellfind/CFindFolder.cpp @@ -32,6 +32,11 @@ static FolderViewColumns g_ColumnDefs[] = {L"Relevance", SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 0} }; +CFindFolder::CFindFolder() : + m_hStopEvent(NULL) +{ +} + static LPITEMIDLIST _ILCreate(LPCWSTR lpszPath, LPCITEMIDLIST lpcFindDataPidl) { int pathLen = (wcslen(lpszPath) + 1) * sizeof(WCHAR); @@ -86,7 +91,7 @@ LRESULT CFindFolder::AddItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHan return hr; } - LPITEMIDLIST lpFSPidl; + CComHeapPtr lpFSPidl; DWORD pchEaten; hr = pShellFolder->ParseDisplayName(NULL, NULL, path, &pchEaten, &lpFSPidl, NULL); if (FAILED_UNEXPECTEDLY(hr)) @@ -96,8 +101,7 @@ LRESULT CFindFolder::AddItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHan } LPITEMIDLIST lpLastFSPidl = ILFindLastID(lpFSPidl); - LPITEMIDLIST lpSearchPidl = _ILCreate(path, lpLastFSPidl); - ILFree(lpFSPidl); + CComHeapPtr lpSearchPidl(_ILCreate(path, lpLastFSPidl)); LocalFree(path); if (!lpSearchPidl) { @@ -106,7 +110,6 @@ LRESULT CFindFolder::AddItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHan UINT uItemIndex; hr = m_shellFolderView->AddObject(lpSearchPidl, &uItemIndex); - ILFree(lpSearchPidl); return hr; } @@ -258,7 +261,7 @@ STDMETHODIMP CFindFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHI WCHAR path[MAX_PATH]; wcscpy(path, (LPCWSTR) apidl[0]->mkid.abID); PathRemoveFileSpecW(path); - LPITEMIDLIST rootPidl = ILCreateFromPathW(path); + CComHeapPtr rootPidl(ILCreateFromPathW(path)); if (!rootPidl) return E_OUTOFMEMORY; PCITEMID_CHILD aFSPidl[1]; @@ -371,7 +374,7 @@ STDMETHODIMP CFindFolder::CallBack(IShellFolder *psf, HWND hwndOwner, IDataObjec for (UINT i = 0; i < cidl; i++) { - LPITEMIDLIST pidl; + CComHeapPtr pidl; DWORD attrs = 0; hr = SHILCreateFromPathW((LPCWSTR) apidl[i]->mkid.abID, &pidl, &attrs); if (SUCCEEDED(hr)) diff --git a/dll/win32/browseui/shellfind/CSearchBar.cpp b/dll/win32/browseui/shellfind/CSearchBar.cpp index 1458137b332..6c9a35aad61 100644 --- a/dll/win32/browseui/shellfind/CSearchBar.cpp +++ b/dll/win32/browseui/shellfind/CSearchBar.cpp @@ -188,7 +188,7 @@ LRESULT CSearchBar::OnSearchButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndC if (FAILED_UNEXPECTEDLY(hr)) return hr; - LPITEMIDLIST findFolderPidl; + CComHeapPtr findFolderPidl; hr = SHParseDisplayName(szShellGuid, NULL, &findFolderPidl, 0, NULL); if (FAILED_UNEXPECTEDLY(hr)) return hr; -- 2.17.1