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:
Eliseo Martínez 2014-11-10 17:23:34 +01:00
parent 8bb2c2c074
commit 5bf6639e0f

View File

@ -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;