From: Jim Meyering Date: Tue, 13 Dec 2016 05:12:14 +0000 (-0800) Subject: dfa: add an assertion to avoid coverity false positive X-Git-Tag: v1.0~6501 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=744c745300fa7b1c73dd9f6b323d3bf4823857e6;p=gnulib.git dfa: add an assertion to avoid coverity false positive * lib/dfa.c (realloc_trans_if_necessary): Otherwise, coverity warned that "newalloc1 - 2" could overflow. --- diff --git a/ChangeLog b/ChangeLog index 8f1671a198..69be242a5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-12 Jim Meyering + + 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 dfa: remove DFA_CASE_FOLD flag in favor of RE_ICASE diff --git a/lib/dfa.c b/lib/dfa.c index 6fee7a1522..c29dd02511 100644 --- 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);