mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 13:03:01 +08:00
Fix memory leak in get_environmental_variable()
This commit is contained in:
parent
4792821a1d
commit
77c90c2df5
@ -167,12 +167,13 @@ namespace vcpkg::System
|
||||
if (sz == 0)
|
||||
return nullopt;
|
||||
|
||||
auto ret = std::make_unique<std::wstring>(sz, L'\0');
|
||||
Checks::check_exit(VCPKG_LINE_INFO, MAXDWORD >= ret->size());
|
||||
auto sz2 = GetEnvironmentVariableW(varname, ret->data(), static_cast<DWORD>(ret->size()));
|
||||
std::wstring ret(sz, L'\0');
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO, MAXDWORD >= ret.size());
|
||||
auto sz2 = GetEnvironmentVariableW(varname, ret.data(), static_cast<DWORD>(ret.size()));
|
||||
Checks::check_exit(VCPKG_LINE_INFO, sz2 + 1 == sz);
|
||||
ret->pop_back();
|
||||
return *ret.release();
|
||||
ret.pop_back();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool is_string_keytype(DWORD hkey_type)
|
||||
|
Loading…
Reference in New Issue
Block a user