mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[BROWSEUI] Fix confusion of StrDupW and SHStrDupW (#7135)
Fix memory leaks. SHStrDupW uses CoTaskMemAlloc. StrDupW uses LocalAlloc. They are different. JIRA issue: N/A Use SHStrDupW instead of StrDupW.
This commit is contained in:
parent
28e7af7531
commit
0fbf4fb8fb
2 changed files with 14 additions and 5 deletions
|
@ -402,7 +402,8 @@ SHExplorerParseCmdLine(_Out_ PEXPLORER_CMDLINE_PARSE_RESULTS pInfo)
|
|||
// The path could not be parsed into an ID List,
|
||||
// so pass it on as a plain string.
|
||||
|
||||
PWSTR field = StrDupW(strField);
|
||||
PWSTR field;
|
||||
SHStrDupW(strField, &field);
|
||||
pInfo->strPath = field;
|
||||
if (field)
|
||||
{
|
||||
|
|
|
@ -428,11 +428,15 @@ static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
|||
FileNameMatch(FindData.cFileName, pSearchData) &&
|
||||
AttribHiddenMatch(FindData.dwFileAttributes, pSearchData))
|
||||
{
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM) StrDupW(szPath));
|
||||
LPWSTR pszPathDup;
|
||||
SHStrDupW(szPath, &pszPathDup);
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM)pszPathDup);
|
||||
uTotalFound++;
|
||||
}
|
||||
status.Format(IDS_SEARCH_FOLDER, FindData.cFileName);
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_UPDATE_STATUS, 0, (LPARAM) StrDupW(status.GetBuffer()));
|
||||
LPWSTR pszStatusDup;
|
||||
SHStrDupW(status.GetBuffer(), &pszStatusDup);
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_UPDATE_STATUS, 0, (LPARAM)pszStatusDup);
|
||||
|
||||
uTotalFound += RecursiveFind(szPath, pSearchData);
|
||||
}
|
||||
|
@ -441,7 +445,9 @@ static UINT RecursiveFind(LPCWSTR lpPath, _SearchData *pSearchData)
|
|||
&& ContentsMatch(szPath, pSearchData))
|
||||
{
|
||||
uTotalFound++;
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM) StrDupW(szPath));
|
||||
LPWSTR pszPathDup;
|
||||
SHStrDupW(szPath, &pszPathDup);
|
||||
PostMessageW(pSearchData->hwnd, WM_SEARCH_ADD_RESULT, 0, (LPARAM)pszPathDup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,7 +471,9 @@ DWORD WINAPI CFindFolder::SearchThreadProc(LPVOID lpParameter)
|
|||
|
||||
CStringW status;
|
||||
status.Format(IDS_SEARCH_FILES_FOUND, uTotalFound);
|
||||
::PostMessageW(data->hwnd, WM_SEARCH_UPDATE_STATUS, 0, (LPARAM) StrDupW(status.GetBuffer()));
|
||||
LPWSTR pszStatusDup;
|
||||
SHStrDupW(status.GetBuffer(), &pszStatusDup);
|
||||
::PostMessageW(data->hwnd, WM_SEARCH_UPDATE_STATUS, 0, (LPARAM)pszStatusDup);
|
||||
::SendMessageW(data->hwnd, WM_SEARCH_STOP, 0, 0);
|
||||
|
||||
CloseHandle(data->hStopEvent);
|
||||
|
|
Loading…
Reference in a new issue