1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

Merge pull request #12633 from xokdvium/wstring-ctor-fiasco

libutil/windows: Finally use the correct constructor for std::wstring
This commit is contained in:
Jörg Thalheim 2025-03-11 13:52:29 +01:00 committed by GitHub
commit d1b21e812d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,8 +13,10 @@ std::optional<OsString> getEnvOs(const OsString & key)
return std::nullopt;
}
// Allocate a buffer to hold the environment variable value
std::wstring value{bufferSize, L'\0'};
/* Allocate a buffer to hold the environment variable value.
WARNING: Do not even think about using uniform initialization here,
we DONT want to call the initializer list ctor accidentally. */
std::wstring value(bufferSize, L'\0');
// Retrieve the environment variable value
DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize);