about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/getopt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/posix/getopt.c b/posix/getopt.c
index 4744e43390..f1add57292 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -521,6 +521,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
   if (optstring[0] == ':')
     print_errors = 0;
 
+  if (argc < 1)
+    return -1;
+
   optarg = NULL;
 
   if (optind == 0 || !__getopt_initialized)