]> Savannah Git Hosting - gnulib.git/commitdiff
dfa: add an assertion to avoid coverity false positive
authorJim Meyering <meyering@fb.com>
Tue, 13 Dec 2016 05:12:14 +0000 (21:12 -0800)
committerJim Meyering <meyering@fb.com>
Wed, 14 Dec 2016 06:38:36 +0000 (22:38 -0800)
* lib/dfa.c (realloc_trans_if_necessary): Otherwise, coverity
warned that "newalloc1 - 2" could overflow.

ChangeLog
lib/dfa.c

index 8f1671a1981301d836df28b8cae2e9b56c5f9537..69be242a5b5685457d814cf40cf1103d5c0d05b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-12  Jim Meyering  <meyering@fb.com>
+
+       dfa: add an assertion to avoid coverity false positive
+       * lib/dfa.c (realloc_trans_if_necessary): Otherwise, coverity
+       warned that "newalloc1 - 2" could overflow.
+
 2016-12-13   Arnold D. Robbins  <arnold@skeeve.com>
 
        dfa: remove DFA_CASE_FOLD flag in favor of RE_ICASE
index 6fee7a1522be959c539b6b4b4f7ab294d36422bb..c29dd02511f1fd81c6827bbca7751fbc8669ac60 100644 (file)
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -2778,6 +2778,7 @@ realloc_trans_if_necessary (struct dfa *d, state_num new_state)
       realtrans = x2nrealloc (realtrans, &newalloc1, sizeof *realtrans);
       realtrans[0] = realtrans[1] = NULL;
       d->trans = realtrans + 2;
+      assert (2 <= newalloc1);
       d->tralloc = newalloc = newalloc1 - 2;
       d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
       d->success = xnrealloc (d->success, newalloc, sizeof *d->success);