Skip to content

Commit d1b21e8

Browse files
authored
Merge pull request #12633 from xokdvium/wstring-ctor-fiasco
libutil/windows: Finally use the correct constructor for std::wstring
2 parents cacab33 + 24fbb45 commit d1b21e8

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)