From: Mikko Rasa Date: Sat, 9 Sep 2023 07:38:43 +0000 (+0300) Subject: Use the length result from getenv_s X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e68a9da7e845226446c1fc100d5eabb0fccea583;p=libs%2Fcore.git Use the length result from getenv_s --- diff --git a/source/core/windows/environ.cpp b/source/core/windows/environ.cpp index 7abf7e5..1bc61de 100644 --- a/source/core/windows/environ.cpp +++ b/source/core/windows/environ.cpp @@ -22,7 +22,7 @@ string getenv(const string &name) char buffer[1024]; size_t result; if(!getenv_s(&result, buffer, sizeof(buffer), name.c_str())) - return buffer; + return string(buffer, (result>0 ? result-1 : 0)); else return string(); }