From 589a0db5e6f98c386b90c3edf9d15f5166d96532 Mon Sep 17 00:00:00 2001
From: Jens Koenen <koenen@vr.rwth-aachen.de>
Date: Thu, 1 Dec 2022 14:01:00 +0100
Subject: [PATCH] Fixed crash when sky image without file extension is
 specified in the command line parameters

---
 src/utility/command_parser.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/utility/command_parser.cpp b/src/utility/command_parser.cpp
index a46039b5..b1647bf8 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;
-- 
GitLab