Skip to content

Commit

Permalink
opj_getopt_long(): avoid infinite loop on invalid or missing value fo…
Browse files Browse the repository at this point in the history
…r an option (#736)
  • Loading branch information
rouault committed Aug 17, 2017
1 parent 1ab6e0e commit 9f7d79f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/bin/common/opj_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,15 @@ int opj_getopt_long(int argc, char * const argv[], const char *optstring,
'-') { /* Has read next input parameter: No arg for current parameter */
if (opj_opterr) {
fprintf(stderr, "%s: option requires an argument\n", arg);
++opj_optind;
return (BADCH);
}
}
}
if (!opj_optarg) { /* missing argument */
if (opj_opterr) {
fprintf(stderr, "%s: option requires an argument\n", arg);
++opj_optind;
return (BADCH);
}
}
Expand Down

0 comments on commit 9f7d79f

Please sign in to comment.