diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-10 17:23:34 +0100 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-11-11 01:43:14 +0100 |
commit | 5bf6639e0fb5698a436efe5105fa5dc8714f67dc (patch) | |
tree | 5faa8846877d409dca057bc1ca966c30fd9a913a /src | |
parent | 8bb2c2c0742c57150655e18cf8418a758cebdce8 (diff) | |
download | rneovim-5bf6639e0fb5698a436efe5105fa5dc8714f67dc.tar.gz rneovim-5bf6639e0fb5698a436efe5105fa5dc8714f67dc.tar.bz2 rneovim-5bf6639e0fb5698a436efe5105fa5dc8714f67dc.zip |
Fix warnings: message.c: delete_first_msg(): Np dereference: FP.
Problem : Dereference of null pointer @ 693.
Diagnostic : False positive.
Rationale : Error condition occurs if `delete_first_msg` is entered two
consecutive times, the firt of which sets leaves history
empty. But, in that case, second entrance should leave at
the `return FAIL`, and thus cannot reach the pointer
dereference.
Resolution : Assert history will be empty after first entrance.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/message.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 58dbee8cf9..0e287268eb 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -12,6 +12,7 @@ #define MESSAGE_FILE /* don't include prototype for smsg() */ +#include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdbool.h> @@ -691,8 +692,10 @@ int delete_first_msg(void) return FAIL; p = first_msg_hist; first_msg_hist = p->next; - if (first_msg_hist == NULL) - last_msg_hist = NULL; /* history is empty */ + if (first_msg_hist == NULL) { /* history is becoming empty */ + assert(msg_hist_len == 1); + last_msg_hist = NULL; + } free(p->msg); free(p); --msg_hist_len; |