fix arg parsing segfault (#595)

This commit is contained in:
Graham Sanderson 2021-10-08 09:01:56 -05:00 committed by GitHub
parent 13be546dc3
commit 0a32023aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,14 +37,14 @@ int main(int argc, char *argv[]) {
for (; !res && i < argc; i++) {
if (argv[i][0] != '-') break;
if (argv[i] == std::string("-o")) {
if (i++ < argc) {
if (++i < argc) {
format = argv[i];
} else {
std::cerr << "error: -o requires format value" << std::endl;
res = 1;
}
} else if (argv[i] == std::string("-p")) {
if (i++ < argc) {
if (++i < argc) {
options.emplace_back(argv[i]);
} else {
std::cerr << "error: -p requires parameter value" << std::endl;