changeset 17785:3f0fd418ac1d v8.1.1889

patch 8.1.1889: Coverity warns for using a NULL pointer commit https://github.com/vim/vim/commit/ea7ecfe2a08877f98edec9b9c26b9e1b3673f00b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 19 20:08:15 2019 +0200 patch 8.1.1889: Coverity warns for using a NULL pointer Problem: Coverity warns for using a NULL pointer. Solution: Use zero for column if pos is NULL.
author Bram Moolenaar <Bram@vim.org>
date Mon, 19 Aug 2019 20:15:04 +0200
parents 0a3a42786ec8
children ebc8c095bbf7
files src/netbeans.c src/version.c
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -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);
 			}
 		    }
--- a/src/version.c
+++ b/src/version.c
@@ -766,6 +766,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1889,
+/**/
     1888,
 /**/
     1887,