]> granicus.if.org Git - vim/commitdiff
patch 8.2.1089: Coverity warns for pointer computation v8.2.1089
authorBram Moolenaar <Bram@vim.org>
Mon, 29 Jun 2020 20:24:56 +0000 (22:24 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 29 Jun 2020 20:24:56 +0000 (22:24 +0200)
Problem:    Coverity warns for pointer computation.
Solution:   Avoid computing a pointer to invalid memory.

src/spellfile.c
src/version.c

index d8cf3d484980c0dc6a3ce9756410c502d770a625..fc365e2a03a78d5043f6a9f7fec6efde1bcffad3 100644 (file)
@@ -5908,7 +5908,8 @@ mkspell(
     spin.si_newcompID = 127;   // start compound ID at first maximum
 
     // default: fnames[0] is output file, following are input files
-    innames = &fnames[1];
+    // When "fcount" is 1 there is only one file.
+    innames = &fnames[fcount == 1 ? 0 : 1];
     incount = fcount - 1;
 
     wfname = alloc(MAXPATHL);
@@ -5922,14 +5923,12 @@ mkspell(
        {
            // For ":mkspell path/en.latin1.add" output file is
            // "path/en.latin1.add.spl".
-           innames = &fnames[0];
            incount = 1;
            vim_snprintf((char *)wfname, MAXPATHL, "%s.spl", fnames[0]);
        }
        else if (fcount == 1)
        {
            // For ":mkspell path/vim" output file is "path/vim.latin1.spl".
-           innames = &fnames[0];
            incount = 1;
            vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL,
                  fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc());
index 48ff321cab0e40dbb1ce1fde9d0e56ab6ef317be..fdf0504f0760d81626a42590b202328a998c9a43 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1089,
 /**/
     1088,
 /**/