From 10cd0723992abc87bfc4d250cd0db10dabf9cf75 Mon Sep 17 00:00:00 2001 From: millert <> Date: Sun, 8 Dec 2002 17:52:26 +0000 Subject: SUS (and apparently 1003.1-2001) say to check optstring for NULL --- src/lib/libc/stdlib/getopt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/libc/stdlib/getopt.c') 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 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $"; +static char *rcsid = "$OpenBSD: getopt.c,v 1.3 2002/12/08 17:52:26 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -63,6 +63,9 @@ getopt(nargc, nargv, ostr) static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ + if (options == NULL) + return (-1); + if (optreset || !*place) { /* update scanning pointer */ optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { -- cgit v1.2.3-55-g6feb