diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-05 21:54:30 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-06 09:51:58 +0100 |
commit | da4c9447a4174dc9c9f15802e8e85cc6e4130f93 (patch) | |
tree | 85f75a615512f2bfce4c31df085debe73853def2 | |
parent | 0bda79a847112702adc07eea03105da26fdef89f (diff) | |
download | rneovim-da4c9447a4174dc9c9f15802e8e85cc6e4130f93.tar.gz rneovim-da4c9447a4174dc9c9f15802e8e85cc6e4130f93.tar.bz2 rneovim-da4c9447a4174dc9c9f15802e8e85cc6e4130f93.zip |
Fix warnings: edit.c: ins_compl_get_exp(): Np dereference (2): FP.
Problems : Dereference of null pointer @ 3615.
Dereference of null pointer @ 3764.
Diagnostic : False positives.
Rationale : `ins_buf` is local static, so maintains value between calls.
This function will be called first when `compl_started` is
false, and in that case it initializes `ins_buf`. After
that, it can be called multiple times with `compl_started`
true, where `ins_buf` will be updated but not to null.
So, when arriving to both points, `ins_buf` should never be
null.
Resolution : Assert `ins_buf` at both points.
-rw-r--r-- | src/nvim/edit.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 31683c1a10..fba8246218 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3613,6 +3613,7 @@ static int ins_compl_get_exp(pos_T *ini) * If 'infercase' is set, don't use 'smartcase' here */ save_p_scs = p_scs; + assert(ins_buf); if (ins_buf->b_p_inf) p_scs = FALSE; @@ -3761,8 +3762,10 @@ static int ins_compl_get_exp(pos_T *ini) compl_started = TRUE; } else { /* Mark a buffer scanned when it has been scanned completely */ - if (type == 0 || type == CTRL_X_PATH_PATTERNS) + if (type == 0 || type == CTRL_X_PATH_PATTERNS) { + assert(ins_buf); ins_buf->b_scanned = TRUE; + } compl_started = FALSE; } |