libc/unistd: getopt: Use argc to end parsing
It should end parsing with argc even the argv are remaining or it may access to invalid address. Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
This commit is contained in:
parent
b11833cbba
commit
d0dd2684ce
@ -393,7 +393,7 @@ int getopt_common(int argc, FAR char * const argv[],
|
||||
|
||||
/* Check for the end of the argument list */
|
||||
|
||||
go->go_optptr = argv[go->go_optind];
|
||||
go->go_optptr = go->go_optind < argc ? argv[go->go_optind] : NULL;
|
||||
if (!go->go_optptr)
|
||||
{
|
||||
/* There are no more arguments, we are finished */
|
||||
|
Loading…
Reference in New Issue
Block a user