]> Savannah Git Hosting - gnulib.git/commitdiff
regex: avoid copying of uninitialized storage
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Oct 2019 00:30:11 +0000 (17:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Oct 2019 01:34:04 +0000 (18:34 -0700)
* config/srclist.txt: Comment out regcomp.c temporarily.
* lib/regcomp.c (build_charclass_op, create_tree) [! (GCC_LINT||lint)]:
Initialize even when not checking for lint, as the behavior is
arguably undefined otherwise and Coverity warns about it.

ChangeLog
config/srclist.txt
lib/regcomp.c

index 0fbb2d43912b46d73e32c2e58bcbfde98c1c940b..8251b83969aaa543d936a5f151892a595ca208f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-10-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       regex: avoid copying of uninitialized storage
+       * config/srclist.txt: Comment out regcomp.c temporarily.
+       * lib/regcomp.c (build_charclass_op, create_tree) [! (GCC_LINT||lint)]:
+       Initialize even when not checking for lint, as the behavior is
+       arguably undefined otherwise and Coverity warns about it.
+
 2019-10-06  Bruno Haible  <bruno@clisp.org>
 
        access tests: Fix test failure when run as root.
index 4a3a5a7af066f6d56dfd0de0b2380b459ba97d42..bceaee8631ec3b6e3956cf3abd63ce4f152770e0 100644 (file)
@@ -52,7 +52,7 @@ $LIBCSRC malloc/scratch_buffer_grow_preserve.c        lib/malloc
 $LIBCSRC malloc/scratch_buffer_set_array_size.c        lib/malloc
 # Temporarily newer in Gnulib than in glibc.
 #$LIBCSRC include/intprops.h             lib
-$LIBCSRC posix/regcomp.c               lib
+#$LIBCSRC posix/regcomp.c              lib
 $LIBCSRC posix/regex.c                 lib
 $LIBCSRC posix/regex.h                 lib
 $LIBCSRC posix/regex_internal.c                lib
index 7525355a9b154427ce2181d095a61fb87e98a21b..c1f7f2b2a4d237a9e4235e6d3252b4ae7d423ead 100644 (file)
@@ -3662,7 +3662,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
   Idx alloc = 0;
 #endif /* not RE_ENABLE_I18N */
   reg_errcode_t ret;
-  re_token_t br_token;
   bin_tree_t *tree;
 
   sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
@@ -3713,11 +3712,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
 #endif
 
   /* Build a tree for simple bracket.  */
-#if defined GCC_LINT || defined lint
-  memset (&br_token, 0, sizeof br_token);
-#endif
-  br_token.type = SIMPLE_BRACKET;
-  br_token.opr.sbcset = sbcset;
+  re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
   tree = create_token_tree (dfa, NULL, NULL, &br_token);
   if (__glibc_unlikely (tree == NULL))
     goto build_word_op_espace;
@@ -3808,11 +3803,7 @@ static bin_tree_t *
 create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
             re_token_type_t type)
 {
-  re_token_t t;
-#if defined GCC_LINT || defined lint
-  memset (&t, 0, sizeof t);
-#endif
-  t.type = type;
+  re_token_t t = { .type = type };
   return create_token_tree (dfa, left, right, &t);
 }