bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH 1/4] regex: avoid copying of uninitialized storage
@ 2019-10-10  1:34 Paul Eggert
  2019-10-10  1:34 ` [PATCH 2/4] regex: simplify by assuming C99 Paul Eggert
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Paul Eggert @ 2019-10-10  1:34 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

* 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          |  8 ++++++++
 config/srclist.txt |  2 +-
 lib/regcomp.c      | 13 ++-----------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0fbb2d439..8251b8396 100644
--- 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.
diff --git a/config/srclist.txt b/config/srclist.txt
index 4a3a5a7af..bceaee863 100644
--- a/config/srclist.txt
+++ b/config/srclist.txt
@@ -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
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 7525355a9..c1f7f2b2a 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -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);
 }
 
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-12 10:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  1:34 [PATCH 1/4] regex: avoid copying of uninitialized storage Paul Eggert
2019-10-10  1:34 ` [PATCH 2/4] regex: simplify by assuming C99 Paul Eggert
2019-10-12 10:41   ` Bruno Haible
2019-10-10  1:34 ` [PATCH 3/4] regex: tell compiler there’s at most 256 arcs out Paul Eggert
2019-10-10  1:34 ` [PATCH 4/4] regex: omit debug assignment when not debugging Paul Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).