Skip to content

Commit

Permalink
Prevent basic_string exception trying to take substr of an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Apr 26, 2023
1 parent 38a7ceb commit ca76cc6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/realizations/catchment/AbstractCLibBmiAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ namespace models {
if (!utils::FileChecker::file_is_readable(bmi_lib_file)) {
//Try alternative extension...
size_t idx = bmi_lib_file.rfind(".");
std::string alt_bmi_lib_file;
std::string alt_bmi_lib_file;
if(bmi_lib_file.length() == 0){
this->init_exception_msg =
"Can't init " + this->model_name + "; library file path is empty";
throw std::runtime_error(this->init_exception_msg);
}
if(bmi_lib_file.substr(idx) == ".so"){
alt_bmi_lib_file = bmi_lib_file.substr(0,idx) + ".dylib";
} else if(bmi_lib_file.substr(idx) == ".dylib"){
Expand Down

0 comments on commit ca76cc6

Please sign in to comment.