1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 20:41:47 +02:00

libutil/windows: Finally use the correct constructor for std::wstring

C++ is very intuitive /s [1]. Fixes #12631.

[1]: https://godbolt.org/z/jMa9GP5sq
This commit is contained in:
Sergei Zimmerman 2025-03-11 10:57:38 +00:00
parent cacab33f0d
commit 24fbb456ba

View file

@ -13,8 +13,10 @@ std::optional<OsString> getEnvOs(const OsString & key)
return std::nullopt; return std::nullopt;
} }
// Allocate a buffer to hold the environment variable value /* Allocate a buffer to hold the environment variable value.
std::wstring value{bufferSize, L'\0'}; 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 // Retrieve the environment variable value
DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize); DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize);