summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/getopt.c
diff options
context:
space:
mode:
authormillert <>2002-12-08 17:52:26 +0000
committermillert <>2002-12-08 17:52:26 +0000
commit10cd0723992abc87bfc4d250cd0db10dabf9cf75 (patch)
treef0fb55650d97ac6ee27da2abf30ad226d8b0195a /src/lib/libc/stdlib/getopt.c
parent9821bb306fe183f16cc79fa833e5bc33c7285584 (diff)
downloadopenbsd-10cd0723992abc87bfc4d250cd0db10dabf9cf75.tar.gz
openbsd-10cd0723992abc87bfc4d250cd0db10dabf9cf75.tar.bz2
openbsd-10cd0723992abc87bfc4d250cd0db10dabf9cf75.zip
SUS (and apparently 1003.1-2001) say to check optstring for NULL
Diffstat (limited to 'src/lib/libc/stdlib/getopt.c')
-rw-r--r--src/lib/libc/stdlib/getopt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/getopt.c b/src/lib/libc/stdlib/getopt.c
index b7f6163662..218887dd32 100644
--- a/src/lib/libc/stdlib/getopt.c
+++ b/src/lib/libc/stdlib/getopt.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $"; 35static char *rcsid = "$OpenBSD: getopt.c,v 1.3 2002/12/08 17:52:26 millert Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <stdio.h> 38#include <stdio.h>
@@ -63,6 +63,9 @@ getopt(nargc, nargv, ostr)
63 static char *place = EMSG; /* option letter processing */ 63 static char *place = EMSG; /* option letter processing */
64 char *oli; /* option letter list index */ 64 char *oli; /* option letter list index */
65 65
66 if (options == NULL)
67 return (-1);
68
66 if (optreset || !*place) { /* update scanning pointer */ 69 if (optreset || !*place) { /* update scanning pointer */
67 optreset = 0; 70 optreset = 0;
68 if (optind >= nargc || *(place = nargv[optind]) != '-') { 71 if (optind >= nargc || *(place = nargv[optind]) != '-') {