From: Mikko Rasa Date: Fri, 15 Sep 2023 21:31:53 +0000 (+0300) Subject: Don't try to fetch the value of a nonexistent environment variable X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=116675a19106b3d17b85299ddb3f98e8978f48f8;p=libs%2Fcore.git Don't try to fetch the value of a nonexistent environment variable --- diff --git a/source/core/windows/environ.cpp b/source/core/windows/environ.cpp index 2dd9d4c..b9ec27a 100644 --- a/source/core/windows/environ.cpp +++ b/source/core/windows/environ.cpp @@ -21,7 +21,7 @@ string getenv(const string &name) MutexLock _lock(env_mutex()); string value; size_t length = 0; - if(!getenv_s(&length, nullptr, 0, name.c_str())) + if(!getenv_s(&length, nullptr, 0, name.c_str()) && length>0) { value.resize(length); if(!getenv_s(&length, &value[0], value.size(), name.c_str()))