Subject: Re: bug#17136: [PATCH] dfa: speed up memory allocation, port to IRIX

From: Jim Meyering <[email-masked]>
Date: Fri, 18 Apr 2014 09:45:57 -0700

Thanks for all the improvements.
However, one of them introduced a bug that caused many new
"make check" failures.  I have fixed it with this just-pushed patch:
From 014d930b33d5c6ddb74e13a2a3d70e20f6cfe8e5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email-masked]>
Date: Fri, 18 Apr 2014 09:36:23 -0700
Subject: [PATCH] dfa: avoid new NULL dereference

* src/dfa.c (dfa_charclass_index): Restore a "+ 1" mistakenly omitted
during recent improvements.  Introduced in v2.18-66-g6a60fd5.
---
 src/dfa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/dfa.c b/src/dfa.c
index eeca257..8463762 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -643,7 +643,7 @@ dfa_charclass_index (struct dfa *d, charclass const s)
   for (i = 0; i < d->cindex; ++i)
     if (equal (s, d->charclasses[i]))
       return i;
-  d->charclasses = maybe_realloc (d->charclasses, d->cindex, &d->calloc,
+  d->charclasses = maybe_realloc (d->charclasses, d->cindex + 1, &d->calloc,
                                   sizeof *d->charclasses);
   ++d->cindex;
   copyset (s, d->charclasses[i]);
--
1.9.0.rc3.9.ge265f1f