diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-30 12:10:39 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-30 12:10:39 +0000 |
commit | 6970e1e36a1ecdb4d330d6ac9ca76f97fa515e36 (patch) | |
tree | e68fc4a39e6022910ad3effe0a1cf209840773f0 /src/spellsuggest.c | |
parent | f10911e5db16f1fe6ab519c5d091ad0c1df0d063 (diff) |
patch 8.2.4258: Coverity warns for array overrunv8.2.4258
Problem: Coverity warns for array overrun.
Solution: Restrict depth to MAXWLEN - 1.
Diffstat (limited to 'src/spellsuggest.c')
-rw-r--r-- | src/spellsuggest.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/spellsuggest.c b/src/spellsuggest.c index 3cd45352fc..e21ac80ced 100644 --- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -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. |