]> git.tdb.fi Git - libs/core.git/commitdiff
Use the length result from getenv_s
authorMikko Rasa <tdb@tdb.fi>
Sat, 9 Sep 2023 07:38:43 +0000 (10:38 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 9 Sep 2023 19:28:16 +0000 (22:28 +0300)
source/core/windows/environ.cpp

index 7abf7e55044cf236b46c73ca387cb3e7d6580398..1bc61dee0f0bffb086eb0053f123d0815430bd43 100644 (file)
@@ -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();
 }