neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 683648a396a804a8d54731283d525f0c34193361
parent 945caeeda2f0a9c660cf05f655dad5d7a88cd4f5
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Mon,  4 Apr 2022 07:46:33 +0800

vim-patch:8.2.4258: Coverity warns for array overrun

Problem:    Coverity warns for array overrun.
Solution:   Restrict depth to MAXWLEN - 1.
https://github.com/vim/vim/commit/6970e1e36a1ecdb4d330d6ac9ca76f97fa515e36

Diffstat:
Msrc/nvim/spell.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nvim/spell.c b/src/nvim/spell.c @@ -3690,7 +3690,7 @@ static void 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. // @@ -3828,7 +3828,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // At end of a prefix or at start of prefixtree: check for // following word. - if (depth < MAXWLEN && (byts[arridx] == 0 || n == STATE_NOPREFIX)) { + if (depth < MAXWLEN - 1 && (byts[arridx] == 0 || n == STATE_NOPREFIX)) { // Set su->su_badflags to the caps type at this position. // Use the caps type until here for the prefix itself. n = nofold_len(fword, sp->ts_fidx, su->su_badptr);