Fix infinite loop in getopt.cpp

Note that the getopt code was looping forever when one of the argument
options was incorrect. Example:
./exiv2 -A 20:00:00 -Y 2018 -O 11 -D 01 ad myImage.tiff
v0.27.3
Luis Díaz Más 7 years ago
parent 09ad415f1f
commit 933ce589a6

@ -105,8 +105,13 @@ namespace Util {
for (;;) {
int c = Util::getopt(argc, argv, optstring.c_str());
if (c == -1) break;
if (c == -1) {
break;
}
errcnt_ += option(c, Util::optarg == 0 ? "" : Util::optarg, Util::optopt);
if (c == '?' ) {
break;
}
}
for (int i = Util::optind; i < argc; i++) {
errcnt_ += nonoption(argv[i]);

Loading…
Cancel
Save