[coap] add message free on error in Cli::CoapSecure::DefaultHandler (#4193)

This commit is contained in:
Yakun Xu
2019-09-20 05:36:05 +08:00
committed by Jonathan Hui
parent c81fc67b82
commit 6fd3a24a43
+6 -3
View File
@@ -558,8 +558,8 @@ void CoapSecure::DefaultHandler(void *aContext, otMessage *aMessage, const otMes
void CoapSecure::DefaultHandler(otMessage *aMessage, const otMessageInfo *aMessageInfo)
{
otError error = OT_ERROR_NONE;
otMessage *responseMessage;
otError error = OT_ERROR_NONE;
otMessage *responseMessage = NULL;
if ((otCoapMessageGetType(aMessage) == OT_COAP_TYPE_CONFIRMABLE) ||
(otCoapMessageGetCode(aMessage) == OT_COAP_CODE_GET))
@@ -576,7 +576,10 @@ void CoapSecure::DefaultHandler(otMessage *aMessage, const otMessageInfo *aMessa
}
exit:
return;
if (error != OT_ERROR_NONE && responseMessage != NULL)
{
otMessageFree(responseMessage);
}
}
#endif // CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER