getopt: silence clang warning
authorEric Blake <eblake@redhat.com>
Wed, 22 Jun 2011 17:17:40 +0000 (11:17 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 22 Jun 2011 17:17:40 +0000 (11:17 -0600)
http://sourceware.org/bugzilla/show_bug.cgi?id=12922

Only triggered by a program that uses "W;" in the short opt string
without providing a longopts array; that can be argued to be a
programmer error, so gnulib won't bother replacing glibc getopt if
it has that bug.

* lib/getopt.c (_getopt_internal_r): Avoid unlikely NULL
dereference.
Reported by Gustavo Martin Domato.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/getopt.c

index 2663e32..8ca76fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-22  Eric Blake  <eblake@redhat.com>
+
+       getopt: silence clang warning
+       * lib/getopt.c (_getopt_internal_r): Avoid unlikely NULL
+       dereference.
+       Reported by Gustavo Martin Domato.
+
 2011-06-22  Jim Meyering  <meyering@redhat.com>
 
        bootstrap: do not insert a blank line into each .gitignore file
index 23510d8..2af8352 100644 (file)
@@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
         return '?';
       }
     /* Convenience. Treat POSIX -W foo same as long option --foo */
-    if (temp[0] == 'W' && temp[1] == ';')
+    if (temp[0] == 'W' && temp[1] == ';' && longopts)
       {
         char *nameend;
         const struct option *p;