opj_getopt.c: avoid crash on invalid input (#301)
This commit is contained in:
parent
e5ab1682a1
commit
3a382d3123
|
@ -160,12 +160,15 @@ again:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[opj_optind][0] == '-') { /* long option */
|
if (argv[opj_optind][0] == '-') { /* long option */
|
||||||
char* arg = argv[opj_optind] + 1;
|
char* arg;
|
||||||
const opj_option_t* o;
|
const opj_option_t* o;
|
||||||
o = longopts;
|
o = longopts;
|
||||||
len = sizeof(longopts[0]);
|
len = sizeof(longopts[0]);
|
||||||
|
|
||||||
if (param > 1) {
|
if (param > 1) {
|
||||||
|
if (opj_optind + 1 >= argc) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
arg = argv[opj_optind + 1];
|
arg = argv[opj_optind + 1];
|
||||||
opj_optind++;
|
opj_optind++;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue