]> Savannah Git Hosting - gnulib.git/commit
dfa: fix dfa-heap-overrun failure
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Sep 2020 01:20:01 +0000 (18:20 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Sep 2020 01:41:32 +0000 (18:41 -0700)
commitcafb61533f5bfb989698e3924f97471498b2422b
tree880c3be8392e55adc097beb684781b63ba5ba7a5
parent8002ca7b56acb46b42eeac4a343e112a8ee283cf
dfa: fix dfa-heap-overrun failure

* lib/dfa.c (reorder_tokens): When setting
map[d->follows[i].elems[j].index], instead of incorrectly assuming
that (i < d->follows[i].elems[j].index), use two loops, one to set
the map array and the other to use it.  The incorrect assumption
caused some elements to be missed, and this in turn caused grep's
dfa-heap-overrun test to fail on Solaris 10 sparc when compiled
with GCC.  I found this bug while investigating
https://buildfarm.opencsw.org/buildbot/builders/ggrep-solaris10-sparc/builds/183
and I think the bug also occurs on GNU/Linux but with more-subtle
symptoms.  The bug predates the recent dfa.c changes; perhaps the
recent changes make the bug more likely.
ChangeLog
lib/dfa.c