Fix a crash or random memory leak when reseting saved environment variable in test_servermodmanager.cpp

master
Loic Blot 2018-03-16 19:34:41 +01:00
parent 478b785bc8
commit e800684ead
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987
1 changed files with 6 additions and 2 deletions

View File

@ -71,11 +71,15 @@ void TestServerModManager::runTests(IGameDef *gamedef)
#ifdef WIN32
{
std::string subgame_path("MINETEST_SUBGAME_PATH=");
subgame_path.append(saved_env_mt_subgame_path);
if (saved_env_mt_subgame_path)
subgame_path.append(saved_env_mt_subgame_path);
_putenv(subgame_path.c_str());
}
#else
setenv("MINETEST_SUBGAME_PATH", saved_env_mt_subgame_path, 1);
if (saved_env_mt_subgame_path)
setenv("MINETEST_SUBGAME_PATH", saved_env_mt_subgame_path, 1);
else
unsetenv("MINETEST_SUBGAME_PATH");
#endif
}