summaryrefslogtreecommitdiff
path: root/src/netbeans.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-19 20:08:15 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-19 20:08:15 +0200
commitea7ecfe2a08877f98edec9b9c26b9e1b3673f00b (patch)
treea5efb8f8e769a84ebb5398cb7b26f1c2e5c95c80 /src/netbeans.c
parent073e4b92e613d22ce7b16e0fbf5c0e40cb5f9b2c (diff)
downloadvim-git-ea7ecfe2a08877f98edec9b9c26b9e1b3673f00b.tar.gz
patch 8.1.1889: Coverity warns for using a NULL pointerv8.1.1889
Problem: Coverity warns for using a NULL pointer. Solution: Use zero for column if pos is NULL.
Diffstat (limited to 'src/netbeans.c')
-rw-r--r--src/netbeans.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/netbeans.c b/src/netbeans.c
index 41b0c31af..9a34460aa 100644
--- 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);
}
}