* lib/dfa.c (compare): Avoid integer overflow when analyzing
very large regular expressions.
2019-12-11 Paul Eggert <eggert@cs.ucla.edu>
+ dfa: fix index overflow
+ * lib/dfa.c (compare): Avoid integer overflow when analyzing
+ very large regular expressions.
+
dfa: update commentary for previous change
* NEWS: Mention the change.
* lib/dfa.c, lib/dfa.h (dfaparse, dfamust, dfacomp): Update comments.
static int
compare (const void *a, const void *b)
{
- int aindex;
- int bindex;
-
- aindex = (int) ((position *) a)->index;
- bindex = (int) ((position *) b)->index;
-
- return aindex - bindex;
+ position const *p = a, *q = b;
+ return p->index < q->index ? -1 : p->index > q->index;
}
static void