Skip to content

Commit

Permalink
Fix memory leak of bootstrap CoAP payload
Browse files Browse the repository at this point in the history
Fix a memory leak, caused by the temporary CoAP payload data (send by
bootstrap server) not deallocated.
  • Loading branch information
parmi93 authored and LukasWoodtli committed Apr 11, 2024
1 parent fc4c431 commit af307ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions core/liblwm2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,21 @@ static void prv_deleteServerList(lwm2m_context_t * context)

static void prv_deleteBootstrapServer(lwm2m_server_t * serverP, void *userData)
{
// TODO should we free location as in prv_deleteServer ?
LOG("Entering");
// TODO should we parse transaction and observation to remove the ones related to this server ?
if (serverP->sessionH != NULL)
{
lwm2m_close_connection(serverP->sessionH, userData);
if (serverP->sessionH != NULL) {
lwm2m_close_connection(serverP->sessionH, userData);
}

lwm2m_free(serverP->location);

while (serverP->blockData != NULL) {
lwm2m_block_data_t *targetP;
targetP = serverP->blockData;
serverP->blockData = serverP->blockData->next;
free_block_data(targetP);
}

lwm2m_free(serverP);
}

Expand Down

0 comments on commit af307ae

Please sign in to comment.