utils: remove double allocation for env variable (#552)
This commit is contained in:
parent
0d22bc482a
commit
e96c4029b8
@ -106,7 +106,7 @@ namespace Utils
|
|||||||
|
|
||||||
void SetLegacyEnvironment()
|
void SetLegacyEnvironment()
|
||||||
{
|
{
|
||||||
wchar_t binaryPath[512];
|
wchar_t binaryPath[512]{};
|
||||||
GetModuleFileNameW(GetModuleHandleW(nullptr), binaryPath, sizeof(binaryPath) / sizeof(wchar_t));
|
GetModuleFileNameW(GetModuleHandleW(nullptr), binaryPath, sizeof(binaryPath) / sizeof(wchar_t));
|
||||||
|
|
||||||
auto* exeBaseName = std::wcsrchr(binaryPath, L'\\');
|
auto* exeBaseName = std::wcsrchr(binaryPath, L'\\');
|
||||||
@ -128,9 +128,8 @@ namespace Utils
|
|||||||
|
|
||||||
const auto _0 = gsl::finally([&] { std::free(buffer); });
|
const auto _0 = gsl::finally([&] { std::free(buffer); });
|
||||||
|
|
||||||
const std::wstring dir{buffer, size};
|
SetCurrentDirectoryW(buffer);
|
||||||
SetCurrentDirectoryW(dir.data());
|
SetDllDirectoryW(buffer);
|
||||||
SetDllDirectoryW(dir.data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HMODULE GetNTDLL()
|
HMODULE GetNTDLL()
|
||||||
|
Loading…
Reference in New Issue
Block a user