getopt(): Could leave optind in undefined state if argc == 1

This commit is contained in:
Gregory Nutt
2014-01-20 13:13:36 -06:00
parent e340fdb88c
commit 297896fe0e
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -264,6 +264,10 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring)
return noarg_ret;
}
/* Restore the initial, uninitialized state */
g_binitialized = false;
optind = 1;
optopt = '?';
return ERROR;
}