diff --git a/core/registration.c b/core/registration.c index 55d6ed8f8..91e25d8a6 100644 --- a/core/registration.c +++ b/core/registration.c @@ -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) { @@ -844,7 +854,7 @@ static int prv_getId(uint8_t * data, { data += 1; length -= 2; - } + } else { return 0;