]> git.tdb.fi Git - libs/core.git/commitdiff
Don't try to fetch the value of a nonexistent environment variable
authorMikko Rasa <tdb@tdb.fi>
Fri, 15 Sep 2023 21:31:53 +0000 (00:31 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 15 Sep 2023 21:31:53 +0000 (00:31 +0300)
source/core/windows/environ.cpp

index 2dd9d4cfec2816fd793ff37ffa7fc78f0e033e8a..b9ec27a1162b209e78d3f9fb2e5bebe7b613d3ec 100644 (file)
@@ -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()))