1
0
forked from aniani/vim

patch 8.2.4258: Coverity warns for array overrun

Problem:    Coverity warns for array overrun.
Solution:   Restrict depth to MAXWLEN - 1.
This commit is contained in:
Bram Moolenaar 2022-01-30 12:10:39 +00:00
parent f10911e5db
commit 6970e1e36a
2 changed files with 4 additions and 2 deletions

View File

@ -1214,7 +1214,7 @@ suggest_try_change(suginfo_T *su)
// Check the maximum score, if we go over it we won't try this change.
#define TRY_DEEPER(su, stack, depth, add) \
(depth < MAXWLEN && stack[depth].ts_score + (add) < su->su_maxscore)
(depth < MAXWLEN - 1 && stack[depth].ts_score + (add) < su->su_maxscore)
/*
* Try finding suggestions by adding/removing/swapping letters.
@ -1373,7 +1373,7 @@ suggest_trie_walk(
// At end of a prefix or at start of prefixtree: check for
// following word.
if (depth < MAXWLEN
if (depth < MAXWLEN - 1
&& (byts[arridx] == 0 || n == (int)STATE_NOPREFIX))
{
// Set su->su_badflags to the caps type at this position.

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4258,
/**/
4257,
/**/