]> Savannah Git Hosting - gnulib.git/commitdiff
argp: Don't pass invalid arguments to isspace() and isalnum().
authorBruno Haible <bruno@clisp.org>
Tue, 8 Dec 2020 18:21:03 +0000 (19:21 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 8 Dec 2020 18:21:03 +0000 (19:21 +0100)
* lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int'
before passing it to isspace() or isalnum().

ChangeLog
lib/argp-help.c

index eaea8df7caab9f902b3a3912614be1fe73ac3b7e..3feedc1d330f22221e9c3ebdf69a89dc882cc612 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-08  Bruno Haible  <bruno@clisp.org>
+
+       argp: Don't pass invalid arguments to isspace() and isalnum().
+       * lib/argp-help.c (canon_doc_option): Cast character to 'unsigned int'
+       before passing it to isspace() or isalnum().
+
 2020-12-08  Bruno Haible  <bruno@clisp.org>
 
        argp: Don't rely on undefined behaviour of _tolower().
index 03fc6c79eb004393b104c54a0cc30e7560d76e42..acab00146fbc3079125b3c19ea6dc0a7bb7cde07 100644 (file)
@@ -720,12 +720,12 @@ canon_doc_option (const char **name)
 {
   int non_opt;
   /* Skip initial whitespace.  */
-  while (isspace (**name))
+  while (isspace ((unsigned char) **name))
     (*name)++;
   /* Decide whether this looks like an option (leading '-') or not.  */
   non_opt = (**name != '-');
   /* Skip until part of name used for sorting.  */
-  while (**name && !isalnum (**name))
+  while (**name && !isalnum ((unsigned char) **name))
     (*name)++;
   return non_opt;
 }