dfa: remove dfa-heap-overrun workaround
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Sep 2020 20:44:34 +0000 (13:44 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Sep 2020 20:46:12 +0000 (13:46 -0700)
* lib/dfa.c (reorder_tokens): Go back to a single pass that
both sets map[*] and does other things.  This reverts
2020-09-14T01:20:01Z!eggert@cs.ucla.edu, which is no longer
needed now that 2020-09-14T13:21:05Z!noritnk@kcn.ne.jp
fixed the underlying problem.

ChangeLog
lib/dfa.c

index 395ac6bafd72e2cada0884c54f470cf91eacf8b9..b668fbd2b7cfd181726b785fd831ba128ed05e96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-09-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+       dfa: remove dfa-heap-overrun workaround
+       * lib/dfa.c (reorder_tokens): Go back to a single pass that
+       both sets map[*] and does other things.  This reverts
+       2020-09-14T01:20:01Z!eggert@cs.ucla.edu, which is no longer
+       neeeded now that 2020-09-14T13:21:05Z!noritnk@kcn.ne.jp
+       fixed the underlying problem.
+
 2020-09-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        dfa: avoid use of uninitialized constraint
index 7851fab779e58c7cfbd9023dc45aa3e68f6d612b..c25a391727d6ba15fcc330740916127fa38aa37b 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -2505,11 +2505,6 @@ reorder_tokens (struct dfa *d)
                           ? xnmalloc (d->nleaves, sizeof *multibyte_prop)
                           : NULL);
 
-  for (idx_t i = 0; i < d->tindex; i++)
-    for (idx_t j = 0; j < d->follows[i].nelem; j++)
-      if (map[d->follows[i].elems[j].index] < 0)
-        map[d->follows[i].elems[j].index] = nleaves++;
-
   for (idx_t i = 0; i < d->tindex; i++)
     {
       if (map[i] < 0)
@@ -2528,7 +2523,12 @@ reorder_tokens (struct dfa *d)
         multibyte_prop[map[i]] = d->multibyte_prop[i];
 
       for (idx_t j = 0; j < d->follows[i].nelem; j++)
-        d->follows[i].elems[j].index = map[d->follows[i].elems[j].index];
+        {
+          if (map[d->follows[i].elems[j].index] == -1)
+            map[d->follows[i].elems[j].index] = nleaves++;
+
+          d->follows[i].elems[j].index = map[d->follows[i].elems[j].index];
+        }
 
       qsort (d->follows[i].elems, d->follows[i].nelem,
              sizeof *d->follows[i].elems, compare);