Skip to content

Commit 9cee5e0

Browse files
Increment OOM counter on OOM
1 parent f4f9466 commit 9cee5e0

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

libcanard/canard.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -444,22 +444,24 @@ static tx_transfer_t* tx_transfer_new(canard_t* const self,
444444
void* const user_context)
445445
{
446446
tx_transfer_t* const tr = mem_alloc_zero(self->mem.tx_transfer, sizeof(tx_transfer_t));
447-
if (tr != NULL) {
448-
FOREACH_IFACE (i) {
449-
tr->index_pending[i] = TREE_NULL;
450-
}
451-
tr->index_deadline = TREE_NULL;
452-
tr->list_agewise = LIST_NULL;
453-
tr->user_context = user_context;
454-
tr->deadline = deadline;
455-
tr->seqno = self->tx.seqno++;
456-
tr->can_id_msb = (can_id_template >> (29U - CAN_ID_MSb_BITS)) & ((1U << CAN_ID_MSb_BITS) - 1U);
457-
tr->fd = fd ? 1U : 0U;
458-
tr->multi_frame = 0U;
459-
tr->first_frame_departed = 0U;
460-
FOREACH_IFACE (i) {
461-
tr->cursor[i] = NULL;
462-
}
447+
if (tr == NULL) {
448+
self->err.oom++;
449+
return NULL;
450+
}
451+
FOREACH_IFACE (i) {
452+
tr->index_pending[i] = TREE_NULL;
453+
}
454+
tr->index_deadline = TREE_NULL;
455+
tr->list_agewise = LIST_NULL;
456+
tr->user_context = user_context;
457+
tr->deadline = deadline;
458+
tr->seqno = self->tx.seqno++;
459+
tr->can_id_msb = (can_id_template >> (29U - CAN_ID_MSb_BITS)) & ((1U << CAN_ID_MSb_BITS) - 1U);
460+
tr->fd = fd ? 1U : 0U;
461+
tr->multi_frame = 0U;
462+
tr->first_frame_departed = 0U;
463+
FOREACH_IFACE (i) {
464+
tr->cursor[i] = NULL;
463465
}
464466
return tr;
465467
}

0 commit comments

Comments
 (0)