utils: remove double allocation for env variable (#552)

This commit is contained in:
Edo 2022-11-07 11:13:13 +00:00 committed by GitHub
parent 0d22bc482a
commit e96c4029b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,7 +106,7 @@ namespace Utils
void SetLegacyEnvironment()
{
wchar_t binaryPath[512];
wchar_t binaryPath[512]{};
GetModuleFileNameW(GetModuleHandleW(nullptr), binaryPath, sizeof(binaryPath) / sizeof(wchar_t));
auto* exeBaseName = std::wcsrchr(binaryPath, L'\\');
@ -128,9 +128,8 @@ namespace Utils
const auto _0 = gsl::finally([&] { std::free(buffer); });
const std::wstring dir{buffer, size};
SetCurrentDirectoryW(dir.data());
SetDllDirectoryW(dir.data());
SetCurrentDirectoryW(buffer);
SetDllDirectoryW(buffer);
}
HMODULE GetNTDLL()