opj_getopt.c: avoid crash on invalid input (#301)

This commit is contained in:
Even Rouault 2017-09-03 00:30:36 +02:00
parent e5ab1682a1
commit 3a382d3123
1 changed files with 4 additions and 1 deletions

View File

@ -160,12 +160,15 @@ again:
}
if (argv[opj_optind][0] == '-') { /* long option */
char* arg = argv[opj_optind] + 1;
char* arg;
const opj_option_t* o;
o = longopts;
len = sizeof(longopts[0]);
if (param > 1) {
if (opj_optind + 1 >= argc) {
return -1;
}
arg = argv[opj_optind + 1];
opj_optind++;
} else {