cpp: prevent crashes when last argument expects a value

This commit is contained in:
Jan Chren (rindeal) 2019-10-19 01:05:54 +02:00 committed by Stefan Haustein
parent 92ecfa55f2
commit 134ca73909

View file

@ -480,14 +480,17 @@ int main(int argc, char* argv[]) {
if (arg == "-0") { if (arg == "-0") {
flags |= FLAG_NOOPT; flags |= FLAG_NOOPT;
} else if (arg == "-c") { } else if (arg == "-c") {
if (i < argc - 1)
columns = std::stoi(argv[++i]); columns = std::stoi(argv[++i]);
} else if (arg == "-d") { } else if (arg == "-d") {
mode = THUMBNAILS; mode = THUMBNAILS;
} else if (arg == "-f") { } else if (arg == "-f") {
mode = FULL_SIZE; mode = FULL_SIZE;
} else if (arg == "-w") { } else if (arg == "-w") {
if (i < argc - 1)
maxWidth = 4 * std::stoi(argv[++i]); maxWidth = 4 * std::stoi(argv[++i]);
} else if (arg == "-h") { } else if (arg == "-h") {
if (i < argc - 1)
maxHeight = 8 * std::stoi(argv[++i]); maxHeight = 8 * std::stoi(argv[++i]);
} else if (arg == "-256") { } else if (arg == "-256") {
flags |= FLAG_MODE_256; flags |= FLAG_MODE_256;