From cec96e1ea3dc55d82316e89a74b52f29abc15827 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Fri, 18 Mar 2022 12:17:50 -0400 Subject: [PATCH] Use calloc instead of malloc for new message queue items This prevents us from accidentally using uninitialized memory --- src/message_queue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/message_queue.c b/src/message_queue.c index 2cb7692..88475a7 100644 --- a/src/message_queue.c +++ b/src/message_queue.c @@ -48,7 +48,7 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, return; } - struct cqueue_msg *new_m = malloc(sizeof(struct cqueue_msg)); + struct cqueue_msg *new_m = calloc(1, sizeof(struct cqueue_msg)); if (new_m == NULL) { exit_toxic_err("failed in cqueue_message", FATALERR_MEMORY); @@ -62,6 +62,7 @@ void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, new_m->time_added = get_unix_time(); new_m->receipt = -1; new_m->next = NULL; + new_m->noread_flag = false; if (q->root == NULL) { new_m->prev = NULL;