Skip to content

Commit

Permalink
Fix: Outbox was leaked in case of initialization failure
Browse files Browse the repository at this point in the history
If the the list allocation fail, outbox must be freed.
  • Loading branch information
euripedesrocha committed Jun 14, 2023
1 parent 63cfec7 commit 5d491a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mqtt_outbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ outbox_handle_t outbox_init(void)
outbox_handle_t outbox = calloc(1, sizeof(struct outbox_t));
ESP_MEM_CHECK(TAG, outbox, return NULL);
outbox->list = calloc(1, sizeof(struct outbox_list_t));
ESP_MEM_CHECK(TAG, outbox->list, return NULL); //TODO: Free outbox on failure
ESP_MEM_CHECK(TAG, outbox->list, {free(outbox); return NULL;});
outbox->size = 0;
STAILQ_INIT(outbox->list);
return outbox;
Expand Down

0 comments on commit 5d491a4

Please sign in to comment.