changeset 15312:68e74bb147d6

getopt: silence clang warning 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>
author Eric Blake <eblake@redhat.com>
date Wed, 22 Jun 2011 11:17:40 -0600
parents 6dbde80a938c
children 8dfa469e2ba8
files ChangeLog lib/getopt.c
diffstat 2 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -829,7 +829,7 @@
         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;