summaryrefslogtreecommitdiff
path: root/src/memline.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-18 13:05:18 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-18 13:05:18 +0200
commit0d3cb73012332964e7a81d7afd1c21d393f45566 (patch)
treef88c8cf7b3b4007b8ba2a064b7b143e8785c39f2 /src/memline.c
parent8055d17388736421d875dd4933c4c93d49a2ab58 (diff)
downloadvim-git-0d3cb73012332964e7a81d7afd1c21d393f45566.tar.gz
patch 8.1.1344: Coverity complains about possibly using a NULL pointerv8.1.1344
Problem: Coverity complains about possibly using a NULL pointer and copying a string into a fixed size buffer. Solution: Check for NULL, even though it should not happen. Use vim_strncpy() instead of strcpy().
Diffstat (limited to 'src/memline.c')
-rw-r--r--src/memline.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/memline.c b/src/memline.c
index 006a8b52d..8772c4a8e 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -1874,7 +1874,7 @@ recover_names(
}
}
- /* check for out-of-memory */
+ // check for out-of-memory
for (i = 0; i < num_names; ++i)
{
if (names[i] == NULL)
@@ -2101,7 +2101,7 @@ get_ctime(time_t thetime, int add_newline)
# endif
/* MSVC returns NULL for an invalid value of seconds. */
if (curtime == NULL)
- STRCPY(buf, _("(Invalid)"));
+ vim_strncpy((char_u *)buf, (char_u *)_("(Invalid)"), sizeof(buf) - 1);
else
(void)strftime(buf, sizeof(buf) - 1, "%a %b %d %H:%M:%S %Y", curtime);
#else
@@ -3374,7 +3374,8 @@ ml_replace_len(
if (newline != NULL)
{
mch_memmove(newline, line, len);
- mch_memmove(newline + len, curbuf->b_ml.ml_line_ptr + oldtextlen, textproplen);
+ mch_memmove(newline + len, curbuf->b_ml.ml_line_ptr
+ + oldtextlen, textproplen);
vim_free(line);
line = newline;
len += (colnr_T)textproplen;