Package: marsshooter Version: 0.7.5-1 Severity: normal Tags: patch Dear Maintainer,
When one tries to launch M.A.R.S. using the -cfg or -data arguments without specifying a path after that argument, for example: $ mars -cfg the game segfaults as the result of accessing the next element of argv without verifying if it is at a valid index. Attached patch solves the issue and displays an error message. Best wishes. -- Sylvain Boilard
diff --git a/src/main.cpp b/src/main.cpp index 8346411..3fa97a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -61,10 +61,16 @@ int main(int argc, char* argv[]) { return 0; } else if (std::string(argv[i]) == "-cfg") { - settings::C_configPath = argv[++i]; + if (++i < argc) + settings::C_configPath = argv[i]; + else + std::cout << "Option \"-cfg\" expects a path to be provided following it.\n"; } else if (std::string(argv[i]) == "-data") { - settings::C_dataPath = argv[++i]; + if (++i < argc) + settings::C_dataPath = argv[i]; + else + std::cout << "Option \"-data\" expects a path to be provided following it.\n"; } else { std::cout << "Unknown option \"" << argv[i] << "\". Use -help for a complete list of supported flags.\n";