diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-04 13:21:26 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-04 13:21:26 +0200 |
commit | 1f3165bc34c6c608584a73f13faec27dd7c7e2fa (patch) | |
tree | 98b930417870b567d8d9d3ff4b2ebf3f11564356 /src/evalfunc.c | |
parent | 61c18652c9374a60ad5ed07a5644217b921c1596 (diff) |
patch 8.1.1974: Coverity warns for using pointer as arrayv8.1.1974
Problem: Coverity warns for using pointer as array.
Solution: Call var2fpos() directly instead of using f_line().
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 6b75addd04..bf4bb8eb9b 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1152,20 +1152,16 @@ non_zero_arg(typval_T *argvars) linenr_T tv_get_lnum(typval_T *argvars) { - typval_T rettv; linenr_T lnum; - int save_type; lnum = (linenr_T)tv_get_number_chk(&argvars[0], NULL); - if (lnum == 0) /* no valid number, try using line() */ - { - rettv.v_type = VAR_NUMBER; - save_type = argvars[1].v_type; - argvars[1].v_type = VAR_UNKNOWN; - f_line(argvars, &rettv); - lnum = (linenr_T)rettv.vval.v_number; - clear_tv(&rettv); - argvars[1].v_type = save_type; + if (lnum == 0) // no valid number, try using arg like line() + { + int fnum; + pos_T *fp = var2fpos(&argvars[0], TRUE, &fnum); + + if (fp != NULL) + lnum = fp->lnum; } return lnum; } |