We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 68fdd17 commit a513534Copy full SHA for a513534
src/futils.cpp
@@ -93,8 +93,18 @@ std::string getEnv(int env_var) {
93
// this check is relying on undefined behavior and might not be effective
94
if (env_var < envHTTPPOST || env_var > envTIMEOUT)
95
throw std::out_of_range("Unexpected env variable");
96
+#ifdef _WIN32
97
+ char* buf = nullptr;
98
+ size_t len;
99
+ if (_dupenv_s(&buf, &len, ENVARKEY[env_var]) == 0 && buf) {
100
+ auto ret = std::string(buf);
101
+ free(buf);
102
+ return ret;
103
+ }
104
+#else
105
if (auto val = std::getenv(ENVARKEY[env_var]))
106
return val;
107
+#endif
108
return ENVARDEF[env_var];
109
}
110
0 commit comments