From ea1f883b199e957134bcb115184280e7122cadbb Mon Sep 17 00:00:00 2001 From: Eliseo Martínez Date: Sat, 8 Nov 2014 13:04:35 +0100 Subject: Fix warnings: ex_eval.c: report_pending(): Np dereference: FP. Problem : Dereference of null pointer @ 711. Diagnostic : False positive. Rationale : Codepath producing error invokes this function with values `action=RPC_DISCARD, pending=CSTP_FINISH, value=NULL`. Now, for some reason, the analyzer is remembering that `value` is null, and that `action` is `RPC_DISCARD`, but it's not remembering that `pending` is `CSTP_FINISH`. Then, it's taking the wrong branch in the switch for `pending`. That path would never occur invocating the function with those values. Resolution : Assert function precondition between `pending` and `value`. This is, let the compiler know that `value` being null implies `pending` not containing `CSTP_THROW`. --- src/nvim/ex_eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_eval.c') diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 3e1672c2e7..fba0b93253 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -9,8 +9,8 @@ /* * ex_eval.c: functions for Ex command line for the +eval feature. */ +#include #include - #include #include "nvim/vim.h" @@ -670,6 +670,7 @@ static void report_pending(int action, int pending, void *value) char *s; int save_msg_silent; + assert(value || !(pending & CSTP_THROW)); switch (action) { case RP_MAKE: -- cgit