Mercurial > vim
changeset 27460:b7ed275ef02f v8.2.4258
patch 8.2.4258: Coverity warns for array overrun
Commit: https://github.com/vim/vim/commit/6970e1e36a1ecdb4d330d6ac9ca76f97fa515e36
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 30 12:10:39 2022 +0000
patch 8.2.4258: Coverity warns for array overrun
Problem: Coverity warns for array overrun.
Solution: Restrict depth to MAXWLEN - 1.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 30 Jan 2022 13:15:04 +0100 |
parents | 5825405e4e2c |
children | 883cfa2dc041 |
files | src/spellsuggest.c src/version.c |
diffstat | 2 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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.