From 24fbb456ba084ae6c63a8e4a565e36f0adfae638 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman <145775305+xokdvium@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:57:38 +0000 Subject: [PATCH] libutil/windows: Finally use the correct constructor for std::wstring C++ is very intuitive /s [1]. Fixes #12631. [1]: https://godbolt.org/z/jMa9GP5sq --- src/libutil/windows/environment-variables.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libutil/windows/environment-variables.cc b/src/libutil/windows/environment-variables.cc index d1093597c..2ed086c60 100644 --- a/src/libutil/windows/environment-variables.cc +++ b/src/libutil/windows/environment-variables.cc @@ -13,8 +13,10 @@ std::optional 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);