mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 07:37:46 +00:00
[mle] properly free message on error in InformPreviousParent() (#2187)
`InformPreviousParent()` uses `Ip6::SendDatagram()` to submit an IPv6 datagram with no next header. However, if `Ip6::SendDatagram()` returns an error, custody of the message buffer remains with the caller. This commit ensures the message buffer is properly freed in this case.
This commit is contained in:
@@ -3298,20 +3298,19 @@ otError Mle::InformPreviousParent(void)
|
||||
messageInfo.SetInterfaceId(netif.GetInterfaceId());
|
||||
|
||||
SuccessOrExit(error = netif.GetIp6().SendDatagram(*message, messageInfo, Ip6::kProtoNone));
|
||||
message = NULL;
|
||||
|
||||
otLogInfoMle(GetInstance(), "Sending message to inform previous parent 0x%04x", mPreviousParentRloc);
|
||||
|
||||
exit:
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
|
||||
if (error != OT_ERROR_NONE)
|
||||
{
|
||||
otLogWarnMle(GetInstance(), "Failed to inform previous parent, error:%s", otThreadErrorToString(error));
|
||||
|
||||
if (message != NULL)
|
||||
{
|
||||
message->Free();
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
Reference in New Issue
Block a user