Skip to content

Commit 5d491a4

Browse files
Fix: Outbox was leaked in case of initialization failure
If the the list allocation fail, outbox must be freed.
1 parent 63cfec7 commit 5d491a4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/mqtt_outbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ outbox_handle_t outbox_init(void)
3333
outbox_handle_t outbox = calloc(1, sizeof(struct outbox_t));
3434
ESP_MEM_CHECK(TAG, outbox, return NULL);
3535
outbox->list = calloc(1, sizeof(struct outbox_list_t));
36-
ESP_MEM_CHECK(TAG, outbox->list, return NULL); //TODO: Free outbox on failure
36+
ESP_MEM_CHECK(TAG, outbox->list, {free(outbox); return NULL;});
3737
outbox->size = 0;
3838
STAILQ_INIT(outbox->list);
3939
return outbox;

0 commit comments

Comments
 (0)