diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2018-03-16 19:34:41 +0100 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2018-03-16 19:34:41 +0100 |
commit | e800684ead568b1103f34efbaefaa973f77d46f0 (patch) | |
tree | 20e2431bd16d124531d6689c29186a2a2868c040 | |
parent | 478b785bc8d8f82b69b23f22ea8a69007db10d9e (diff) | |
download | minetest-e800684ead568b1103f34efbaefaa973f77d46f0.tar.gz minetest-e800684ead568b1103f34efbaefaa973f77d46f0.tar.bz2 minetest-e800684ead568b1103f34efbaefaa973f77d46f0.zip |
Fix a crash or random memory leak when reseting saved environment variable in test_servermodmanager.cpp
-rw-r--r-- | src/unittest/test_servermodmanager.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/unittest/test_servermodmanager.cpp b/src/unittest/test_servermodmanager.cpp index cb43babf9..72ac7c6bf 100644 --- a/src/unittest/test_servermodmanager.cpp +++ b/src/unittest/test_servermodmanager.cpp @@ -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 } |