From e5336bd2af180c8414a7421aff0c2ebf5936bf16 Mon Sep 17 00:00:00 2001 From: He Yang <1160386205@qq.com> Date: Thu, 21 May 2020 06:21:26 +0800 Subject: [PATCH] [RAPPS] Rapps trivial fixes (#2819) - Specify W explicitly for URL_COMPONENTS; - Remove malloc/free for once used HostName in urlComponents; - Use PathAppendW to operate on path string. --- base/applications/rapps/loaddlg.cpp | 5 +---- base/applications/rapps/winmain.cpp | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/base/applications/rapps/loaddlg.cpp b/base/applications/rapps/loaddlg.cpp index b394d0d572a..cc88af6cc16 100644 --- a/base/applications/rapps/loaddlg.cpp +++ b/base/applications/rapps/loaddlg.cpp @@ -563,7 +563,7 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) unsigned char lpBuffer[4096]; LPCWSTR lpszAgent = L"RApps/1.0"; - URL_COMPONENTS urlComponents; + URL_COMPONENTSW urlComponents; size_t urlLength, filenameLength; const ATL::CSimpleArray &InfoArray = static_cast(param)->AppInfo; @@ -698,8 +698,6 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) urlLength = InfoArray[iAppId].szUrl.GetLength(); urlComponents.dwSchemeLength = urlLength + 1; urlComponents.lpszScheme = (LPWSTR) malloc(urlComponents.dwSchemeLength * sizeof(WCHAR)); - urlComponents.dwHostNameLength = urlLength + 1; - urlComponents.lpszHostName = (LPWSTR) malloc(urlComponents.dwHostNameLength * sizeof(WCHAR)); if (!InternetCrackUrlW(InfoArray[iAppId].szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents)) { @@ -766,7 +764,6 @@ unsigned int WINAPI CDownloadManager::ThreadFunc(LPVOID param) } free(urlComponents.lpszScheme); - free(urlComponents.lpszHostName); #ifdef USE_CERT_PINNING // are we using HTTPS to download the RAPPS update package? check if the certificate is original diff --git a/base/applications/rapps/winmain.cpp b/base/applications/rapps/winmain.cpp index f4e4a4f4a07..1c351e864f8 100644 --- a/base/applications/rapps/winmain.cpp +++ b/base/applications/rapps/winmain.cpp @@ -63,7 +63,9 @@ VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo) szDownloadDir.ReleaseBuffer(); } - szDownloadDir += L"\\RAPPS Downloads"; + PathAppendW(szDownloadDir.GetBuffer(MAX_PATH), L"\\RAPPS Downloads"); + szDownloadDir.ReleaseBuffer(); + ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir, _countof(pSettingsInfo->szDownloadDir), szDownloadDir.GetString(),