]> granicus.if.org Git - vim/commitdiff
patch 8.1.0501: cppcheck warns for using array index before bounds check v8.1.0501
authorBram Moolenaar <Bram@vim.org>
Tue, 30 Oct 2018 21:15:55 +0000 (22:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 30 Oct 2018 21:15:55 +0000 (22:15 +0100)
Problem:    Cppcheck warns for using array index before bounds check.
Solution:   Swap the conditions. (Dominique Pelle)

src/memline.c
src/version.c

index 9789349faf495caa60bda5c5fcbebfb15e342887..1d65a44d8f0f94198e53f085a8f92cf2a6eddcbe 100644 (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;
index 9d700e2ba3dea0ae91b2d27e9d92689cca62d9fb..73d06215ffce192486047338be718f52022d0a4b 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    501,
 /**/
     500,
 /**/