mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
8bb2c2c074
commit
5bf6639e0f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user