Skip to content

Commit

Permalink
chore: set pointers to null after free in transaction_free
Browse files Browse the repository at this point in the history
more defensive coding style

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
  • Loading branch information
broglep-work authored and mlasch committed Sep 28, 2021
1 parent c469ded commit 14b4500
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion coap/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,19 @@ void transaction_free(lwm2m_transaction_t * transacP)
{
coap_free_header(transacP->message);
lwm2m_free(transacP->message);
transacP->message = NULL;
}

if (transacP->payload) {
lwm2m_free(transacP->payload);
transacP->payload = NULL;
}

if (transacP->buffer) lwm2m_free(transacP->buffer);
if (transacP->buffer) {
lwm2m_free(transacP->buffer);
transacP->buffer = NULL;
}

lwm2m_free(transacP);
}

Expand Down

0 comments on commit 14b4500

Please sign in to comment.