diff --git a/src/cpp/multisolver_interface/environment.cc b/src/cpp/multisolver_interface/environment.cc index e4f77ca5a..d3f9d1f33 100644 --- a/src/cpp/multisolver_interface/environment.cc +++ b/src/cpp/multisolver_interface/environment.cc @@ -223,14 +223,13 @@ std::string GetXpressVarFromEnvironmentVariables(const char* XPRESS_var) { if (requiredSize == 0) { std::cerr << "[Windows getenv_s function]: " << XPRESS_var << " doesn't exist!\n"; - } - - xpress_home_from_env.resize(requiredSize); - - // Get the value of the LIB environment variable. - getenv_s(&requiredSize, xpress_home_from_env.data(), requiredSize, - XPRESS_var); + } else { + xpress_home_from_env.resize(requiredSize); + // Get the value of the LIB environment variable. + getenv_s(&requiredSize, xpress_home_from_env.data(), requiredSize, + XPRESS_var); + } #else char* path = nullptr; path = getenv(XPRESS_var);