1
0
forked from aniani/vim

patch 8.1.1974: Coverity warns for using pointer as array

Problem:    Coverity warns for using pointer as array.
Solution:   Call var2fpos() directly instead of using f_line().
This commit is contained in:
Bram Moolenaar
2019-09-04 13:21:26 +02:00
parent 61c18652c9
commit 1f3165bc34
2 changed files with 8 additions and 10 deletions

View File

@@ -1152,20 +1152,16 @@ non_zero_arg(typval_T *argvars)
linenr_T linenr_T
tv_get_lnum(typval_T *argvars) tv_get_lnum(typval_T *argvars)
{ {
typval_T rettv;
linenr_T lnum; linenr_T lnum;
int save_type;
lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL); lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL);
if (lnum == 0) /* no valid number, try using line() */ if (lnum == 0) // no valid number, try using arg like line()
{ {
rettv.v_type = VAR_NUMBER; int fnum;
save_type = argvars[1].v_type; pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum);
argvars[1].v_type = VAR_UNKNOWN;
f_line(argvars, &rettv); if (fp != NULL)
lnum = (linenr_T)rettv.vval.v_number; lnum = fp->lnum;
clear_tv(&rettv);
argvars[1].v_type = save_type;
} }
return lnum; return lnum;
} }

View File

@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1974,
/**/ /**/
1973, 1973,
/**/ /**/