mirror of
https://github.com/apache/nuttx.git
synced 2026-08-24 06:58:27 +00:00
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
1 changed files with 1 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue