0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.0501: cppcheck warns for using array index before bounds check

Problem:    Cppcheck warns for using array index before bounds check.
Solution:   Swap the conditions. (Dominique Pelle)
This commit is contained in:
Bram Moolenaar
2018-10-30 22:15:55 +01:00
parent 833e5dab14
commit a9a8e04eab
2 changed files with 4 additions and 2 deletions

View File

@@ -5029,8 +5029,8 @@ ml_updatechunk(
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)
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;