external/wakaama : fixes memory leakage in tcp api
This patch fixes memory leakage issue in tcp api.
Without this commit, 32 bytes are not released when client is
registered over tcp.
@@ -87,7 +87,8 @@ static int prv_getRegistrationQuery(lwm2m_context_t * contextP,
index += res;
}
- if (contextP->protocol == COAP_TCP)
+ if (contextP->protocol == COAP_TCP
+ || contextP->protocol == COAP_TCP_TLS)
{
/*
* We need to append the token to the parameters list
@@ -100,6 +101,7 @@ static int prv_getRegistrationQuery(lwm2m_context_t * contextP,
{
int size = 1;
lwm2m_data_t * dataP = lwm2m_data_new(size);
+ if (dataP == NULL) return 0;
dataP->id = LWM2M_SECURITY_SECRET_KEY_ID;
obj->readFunc(0, &size, &dataP, obj);
@@ -129,6 +131,7 @@ static int prv_getRegistrationQuery(lwm2m_context_t * contextP,
index += res;
lwm2m_free(secret);
}
+ lwm2m_data_free(size, dataP);
}
}
