[common] option: fix invalid access of null/invalid options

This commit is contained in:
Geoffrey McRae 2019-05-21 11:34:50 +10:00
parent 2d5f6d65ce
commit 06c229dfd4
2 changed files with 6 additions and 7 deletions

View File

@ -1 +1 @@
a12-192-gb9841351b4+1 a12-193-g2d5f6d65ce+1

View File

@ -267,15 +267,14 @@ bool option_parse(int argc, char * argv[])
if (state.options[i]->shortopt == argv[a][1]) if (state.options[i]->shortopt == argv[a][1])
{ {
o = state.options[i]; o = state.options[i];
if (o->type != OPTION_TYPE_BOOL && a < argc - 1)
{
++a;
value = strdup(argv[a]);
}
break; break;
} }
} }
if (o->type != OPTION_TYPE_BOOL && a < argc - 1)
{
++a;
value = strdup(argv[a]);
}
} }
else else
{ {