diff --git a/src/cpp/lpnamer/helper/common_lpnamer.h b/src/cpp/lpnamer/helper/common_lpnamer.h index fac4f9969..883670121 100644 --- a/src/cpp/lpnamer/helper/common_lpnamer.h +++ b/src/cpp/lpnamer/helper/common_lpnamer.h @@ -50,6 +50,9 @@ inline std::vector split(const std::string& original, inline FILE* OpenLogPtr(const std::filesystem::path& log_file) { FILE* log_file_ptr = NULL; + if (log_file.empty()) { + return log_file_ptr; + } #ifdef __linux__ if ((log_file_ptr = fopen(log_file.string().c_str(), "a+")) == nullptr) #elif _WIN32 diff --git a/src/cpp/multisolver_interface/SolverCbc.cpp b/src/cpp/multisolver_interface/SolverCbc.cpp index 4d8c7c74e..24c7b60f0 100644 --- a/src/cpp/multisolver_interface/SolverCbc.cpp +++ b/src/cpp/multisolver_interface/SolverCbc.cpp @@ -73,9 +73,11 @@ SolverCbc::~SolverCbc() { } void SolverCbc::set_fp(FILE *fp) { - setvbuf(fp, nullptr, _IONBF, 0); - _clp_inner_solver.messageHandler()->setFilePointer(fp); - _cbc.messageHandler()->setFilePointer(fp); + if (fp) { + setvbuf(fp, nullptr, _IONBF, 0); + _clp_inner_solver.messageHandler()->setFilePointer(fp); + _cbc.messageHandler()->setFilePointer(fp); + } } int SolverCbc::get_number_of_instances() { return _NumberOfProblems; } diff --git a/src/cpp/multisolver_interface/SolverClp.cpp b/src/cpp/multisolver_interface/SolverClp.cpp index d675a027b..2c3fc43c1 100644 --- a/src/cpp/multisolver_interface/SolverClp.cpp +++ b/src/cpp/multisolver_interface/SolverClp.cpp @@ -70,8 +70,10 @@ SolverClp::~SolverClp() { } void SolverClp::set_fp(FILE *fp) { - setvbuf(_fp, nullptr, _IONBF, 0); - _clp.messageHandler()->setFilePointer(_fp); + if (fp) { + setvbuf(_fp, nullptr, _IONBF, 0); + _clp.messageHandler()->setFilePointer(_fp); + } } int SolverClp::get_number_of_instances() { return _NumberOfProblems; }