diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-11-01 04:53:46 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-11-01 09:53:46 +0100 |
commit | f9fe903579033791e4233e8d55613634492702f5 (patch) | |
tree | a37a8fc28e2bfd81a737b1a68b63c7aeec2e5550 | |
parent | b24209dcf5d9d4c14522a7da1a571a9e9520260f (diff) | |
download | rneovim-f9fe903579033791e4233e8d55613634492702f5.tar.gz rneovim-f9fe903579033791e4233e8d55613634492702f5.tar.bz2 rneovim-f9fe903579033791e4233e8d55613634492702f5.zip |
vim-patch:8.1.0501: cppcheck warns for using array index before bounds check (#9178)
Problem: Cppcheck warns for using array index before bounds check.
Solution: Swap the conditions. (Dominique Pelle)
https://github.com/vim/vim/commit/a9a8e04eab106c1d21381f79f8965fe50b94e235
-rw-r--r-- | src/nvim/memline.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 9d1f542973..aad1750c85 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3709,9 +3709,9 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) curix++) { curline += buf->b_ml.ml_chunksize[curix].mlcs_numlines; } - } else if (line >= curline + buf->b_ml.ml_chunksize[curix].mlcs_numlines - && curix < buf->b_ml.ml_usedchunks - 1) { - /* Adjust cached curix & curline */ + } else if (curix < buf->b_ml.ml_usedchunks - 1 + && line >= curline + buf->b_ml.ml_chunksize[curix].mlcs_numlines) { + // Adjust cached curix & curline curline += buf->b_ml.ml_chunksize[curix].mlcs_numlines; curix++; } |