From da4c9447a4174dc9c9f15802e8e85cc6e4130f93 Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Wed, 5 Nov 2014 21:54:30 +0100 Subject: 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. --- src/nvim/edit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/nvim/edit.c') 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; } -- cgit