Mercurial > vim
changeset 14980:c98810dfebaf v8.1.0501
patch 8.1.0501: cppcheck warns for using array index before bounds check
commit https://github.com/vim/vim/commit/a9a8e04eab106c1d21381f79f8965fe50b94e235
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 30 22:15:55 2018 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 30 Oct 2018 22:30:07 +0100 |
parents | a5f5944300fc |
children | 1c12ef803c7d |
files | src/memline.c src/version.c |
diffstat | 2 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/memline.c +++ b/src/memline.c @@ -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;