[host] fix build in VS++

This commit is contained in:
Geoffrey McRae 2017-12-18 00:06:53 +11:00
parent 0ac1992019
commit 4e6c1ea648

View File

@ -36,7 +36,14 @@ public:
{ {
std::string defaultPath; std::string defaultPath;
#if __MINGW32__
const char * libPath = getenv("SystemRoot"); const char * libPath = getenv("SystemRoot");
const size_t libPathLen = strlen(libPath);
#else
char * libPath;
size_t libPathLen;
_dupenv_s(&libPath, &libPathLen, "SystemRoot");
#endif
if (!libPath) if (!libPath)
{ {
@ -44,9 +51,12 @@ public:
return defaultPath; return defaultPath;
} }
if (!strlen(libPath)) if (!libPathLen)
{ {
DEBUG_ERROR("The SystemRoot environment variable is not set"); DEBUG_ERROR("The SystemRoot environment variable is not set");
#ifndef __MINGW32__
free(libPath);
#endif
return defaultPath; return defaultPath;
} }
#ifdef _WIN64 #ifdef _WIN64
@ -60,6 +70,9 @@ public:
{ {
defaultPath = std::string(libPath) + "\\System32"; defaultPath = std::string(libPath) + "\\System32";
} }
#endif
#ifndef __MINGW32__
free(libPath);
#endif #endif
return defaultPath; return defaultPath;
} }