mirror of
https://github.com/vim/vim.git
synced 2025-10-18 07:54:29 -04:00
patch 8.1.1344: Coverity complains about possibly using a NULL pointer
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().
This commit is contained in:
12
src/change.c
12
src/change.c
@@ -193,12 +193,16 @@ check_recorded_changes(
|
||||
// can be merged.
|
||||
di = dict_find(li->li_tv.vval.v_dict,
|
||||
(char_u *)"end", -1);
|
||||
nr = tv_get_number(&di->di_tv);
|
||||
if (lnume > nr)
|
||||
di->di_tv.vval.v_number = lnume;
|
||||
if (di != NULL)
|
||||
{
|
||||
nr = tv_get_number(&di->di_tv);
|
||||
if (lnume > nr)
|
||||
di->di_tv.vval.v_number = lnume;
|
||||
}
|
||||
di = dict_find(li->li_tv.vval.v_dict,
|
||||
(char_u *)"added", -1);
|
||||
di->di_tv.vval.v_number += xtra;
|
||||
if (di != NULL)
|
||||
di->di_tv.vval.v_number += xtra;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1344,
|
||||
/**/
|
||||
1343,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user