From: Eric Blake Date: Wed, 22 Jun 2011 17:17:40 +0000 (-0600) Subject: getopt: silence clang warning X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbf381169705782b144b2733798a62c11aa473a5;p=pspp 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 --- diff --git a/ChangeLog b/ChangeLog index 2663e3246f..8ca76fab7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-06-22 Eric Blake + + getopt: silence clang warning + * lib/getopt.c (_getopt_internal_r): Avoid unlikely NULL + dereference. + Reported by Gustavo Martin Domato. + 2011-06-22 Jim Meyering bootstrap: do not insert a blank line into each .gitignore file diff --git a/lib/getopt.c b/lib/getopt.c index 23510d8afe..2af8352ee9 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -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;