Skip to content

Commit 24fbb45

Browse files
committed
libutil/windows: Finally use the correct constructor for std::wstring
C++ is very intuitive /s [1]. Fixes #12631. [1]: https://godbolt.org/z/jMa9GP5sq
1 parent cacab33 commit 24fbb45

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libutil/windows/environment-variables.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ std::optional<OsString> getEnvOs(const OsString & key)
1313
return std::nullopt;
1414
}
1515

16-
// Allocate a buffer to hold the environment variable value
17-
std::wstring value{bufferSize, L'\0'};
16+
/* Allocate a buffer to hold the environment variable value.
17+
WARNING: Do not even think about using uniform initialization here,
18+
we DONT want to call the initializer list ctor accidentally. */
19+
std::wstring value(bufferSize, L'\0');
1820

1921
// Retrieve the environment variable value
2022
DWORD resultSize = GetEnvironmentVariableW(key.c_str(), &value[0], bufferSize);

0 commit comments

Comments
 (0)