From cbf381169705782b144b2733798a62c11aa473a5 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 22 Jun 2011 11:17:40 -0600 Subject: [PATCH] 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 --- ChangeLog | 7 +++++++ lib/getopt.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2663e3246..8ca76fab7 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 23510d8af..2af8352ee 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; -- 2.11.0