1
0
forked from aniani/vim

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:
Bram Moolenaar
2019-05-18 13:05:18 +02:00
parent 8055d17388
commit 0d3cb73012
3 changed files with 14 additions and 7 deletions

View File

@@ -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;
}
}