Skip to content

Commit

Permalink
Fix for issue eclipse-wakaama#354: Potential memory leak in prv_updat…
Browse files Browse the repository at this point in the history
…eRegistration

Signed-off-by: Frederic DUR <fdur@sierrawireless.com>
  • Loading branch information
fdur committed Feb 2, 2018
1 parent 6727c27 commit 004c45d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions core/registration.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,19 @@ static int prv_updateRegistration(lwm2m_context_t * contextP,
if (withObjects == true)
{
payload_length = object_getRegisterPayloadBufferLength(contextP);
if(payload_length == 0) return COAP_500_INTERNAL_SERVER_ERROR;
if(payload_length == 0)
{
transaction_free(transaction);
return COAP_500_INTERNAL_SERVER_ERROR;
}

payload = lwm2m_malloc(payload_length);
if(!payload) return COAP_500_INTERNAL_SERVER_ERROR;
if(!payload)
{
transaction_free(transaction);
return COAP_500_INTERNAL_SERVER_ERROR;
}

payload_length = object_getRegisterPayload(contextP, payload, payload_length);
if(payload_length == 0)
{
Expand Down Expand Up @@ -844,7 +854,7 @@ static int prv_getId(uint8_t * data,
{
data += 1;
length -= 2;
}
}
else
{
return 0;
Expand Down

0 comments on commit 004c45d

Please sign in to comment.