* lib/dfa.c (merge_nfa_state): Do not initialize the constraint
to zero here.
(dfaoptimize): Do it here instead, via xcalloc. This prevents the
use of an uninitialized constraint by later code when ! (flags[i]
& OPT_QUEUED) means merge_nfa_state was not called to initialize
the constraint. Problem found by running 'valgrind src/grep -E
'(^| )*(a|b)*(c|d)*( |$)' < /dev/null' on Ubuntu 18.04.5 x86-64.
2020-09-13 Paul Eggert <eggert@cs.ucla.edu>
+ dfa: avoid use of uninitialized constraint
+ * lib/dfa.c (merge_nfa_state): Do not initialize the constraint
+ to zero here.
+ (dfaoptimize): Do it here instead, via xcalloc. This prevents the
+ use of an uninitialized constraint by later code when ! (flags[i]
+ & OPT_QUEUED) means merge_nfa_state was not called to initialize
+ the constraint. Problem found by running 'valgrind src/grep -E
+ '(^| )*(a|b)*(c|d)*( |$)' < /dev/null' on Ubuntu 18.04.5 x86-64.
+
dfa: assume C99 in reorder_tokens
* lib/dfa.c (reorder_tokens): Assume C99 and simplify.
position_set *follows = d->follows;
idx_t nelem = 0;
- d->constraints[tindex] = 0;
-
for (idx_t i = 0; i < follows[tindex].nelem; i++)
{
idx_t sindex = follows[tindex].elems[i].index;
position_set *merged = &merged0;
alloc_position_set (merged, d->nleaves);
- d->constraints = xnmalloc (d->tindex, sizeof *d->constraints);
+ d->constraints = xcalloc (d->tindex, sizeof *d->constraints);
for (idx_t i = 0; i < d->tindex; i++)
if (flags[i] & OPT_QUEUED)