diff --git a/src/utility/command_parser.cpp b/src/utility/command_parser.cpp index a46039b5ad61ded1dd17d0f651eb5a01004f19ce..b1647bf8d5cfd61fc20729d1523e5ca9c07f5e56 100644 --- a/src/utility/command_parser.cpp +++ b/src/utility/command_parser.cpp @@ -50,11 +50,22 @@ bool CommandParser::parse_command(const argh::parser& cmd_line) if (parameter.first == "sky-sphere") { std::string path = parameter.second; - std::string extension = path.substr(path.find_last_of('.')); + std::size_t extension_begin = path.find_last_of('.'); + + if (extension_begin == std::string::npos) + { + std::cout << "Invalid file format for parameter 'sky-sphere'. Only .hdr images supported. Use option --help to get more information." << std::endl; + + return false; + } + + std::string extension = path.substr(extension_begin); if (extension != ".hdr") { std::cout << "Invalid file format for parameter 'sky-sphere'. Only .hdr images supported. Use option --help to get more information." << std::endl; + + return false; } this->sky_sphere_path = path;