]> granicus.if.org Git - vim/commitdiff
patch 8.1.1889: Coverity warns for using a NULL pointer v8.1.1889
authorBram Moolenaar <Bram@vim.org>
Mon, 19 Aug 2019 18:08:15 +0000 (20:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Aug 2019 18:08:15 +0000 (20:08 +0200)
Problem:    Coverity warns for using a NULL pointer.
Solution:   Use zero for column if pos is NULL.

src/netbeans.c
src/version.c

index 41b0c31af9e7d4eb3291e4cb93da535b59514c22..9a34460aaaa2f93bf50830cfaff31539e464a2b6 100644 (file)
@@ -1389,17 +1389,18 @@ nb_do_cmd(
                            && ((pos != NULL && pos->col > 0)
                                || (lnum == 1 && buf_was_empty)))
                    {
-                       char_u *oldline = ml_get(lnum);
-                       char_u *newline;
+                       char_u  *oldline = ml_get(lnum);
+                       char_u  *newline;
+                       int     col = pos == NULL ? 0 : pos->col;
 
                        /* Insert halfway a line. */
                        newline = alloc(STRLEN(oldline) + len + 1);
                        if (newline != NULL)
                        {
-                           mch_memmove(newline, oldline, (size_t)pos->col);
-                           newline[pos->col] = NUL;
+                           mch_memmove(newline, oldline, (size_t)col);
+                           newline[col] = NUL;
                            STRCAT(newline, args);
-                           STRCAT(newline, oldline + pos->col);
+                           STRCAT(newline, oldline + col);
                            ml_replace(lnum, newline, FALSE);
                        }
                    }
index 85d481a32a2f7a629ae9ddc7698682982b6de4c0..d7bdfa2c0681e82b003a51e4fc62c76106a6e814 100644 (file)
@@ -765,6 +765,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1889,
 /**/
     1888,
 /**/