Skip to content

Commit

Permalink
Update getenv to check for returned null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jun 12, 2024
1 parent 2fd1fb7 commit eead4cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tmx/TmxUtils/src/simulation/SimulationEnvUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace tmx::utils::sim{

std::string get_sim_config(const char *config_name, bool required) {
if (is_simulation_mode() && config_name) {
try {
if ( std::getenv(config_name) != nullptr) {
std::string config = std::getenv(config_name);
return config;
}
catch(const std::logic_error &e) {
else {
std::string config_name_str = config_name;
if ( required ) {
throw TmxException("Required simulation config " + config_name_str + " not set!");
Expand Down

0 comments on commit eead4cb

Please sign in to comment.