1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-22 17:03:26 +01:00

Use calloc instead of malloc for new message queue items

This prevents us from accidentally using uninitialized memory
This commit is contained in:
jfreegman 2022-03-18 12:17:50 -04:00
parent eb7e6151a2
commit cec96e1ea3
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

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