]> granicus.if.org Git - vim/commitdiff
patch 8.2.4258: Coverity warns for array overrun v8.2.4258
authorBram Moolenaar <Bram@vim.org>
Sun, 30 Jan 2022 12:10:39 +0000 (12:10 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 30 Jan 2022 12:10:39 +0000 (12:10 +0000)
Problem:    Coverity warns for array overrun.
Solution:   Restrict depth to MAXWLEN - 1.

src/spellsuggest.c
src/version.c

index 3cd45352fc397dc2d65d866aca72d9f92ee8ae4d..e21ac80ced6f3b7525611b332c069f45716292fb 100644 (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.
index 0d84d580af466a1fb4c1f38eb0957b861153e692..a0f0037f749c04bf47280513c81e80425bd193d2 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4258,
 /**/
     4257,
 /**/