From e68a9da7e845226446c1fc100d5eabb0fccea583 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 9 Sep 2023 10:38:43 +0300 Subject: [PATCH] Use the length result from getenv_s --- source/core/windows/environ.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); } -- 2.45.2