[core] do not use FreeMessageOnError() on nonnull pointer (#8118)

This commit is contained in:
Jonathan Hui
2022-09-06 11:19:09 -07:00
parent a53715b231
commit ae4c28c5ae
2 changed files with 7 additions and 3 deletions
+2 -2
View File
@@ -219,10 +219,10 @@ void Server::SendResponse(Header aHeader,
error = aSocket.SendTo(aMessage, aMessageInfo);
FreeMessageOnError(&aMessage, error);
if (error != kErrorNone)
{
// do not use `FreeMessageOnError()` to avoid null check on nonnull pointer
aMessage.Free();
LogWarn("failed to send DNS-SD reply: %s", ErrorToString(error));
}
else
+5 -1
View File
@@ -1640,7 +1640,11 @@ void Mle::SendDelayedResponse(TxMessage &aMessage, const DelayedResponseMetadata
}
exit:
FreeMessageOnError(&aMessage, error);
if (error != kErrorNone)
{
// do not use `FreeMessageOnError()` to avoid null check on nonnull pointer
aMessage.Free();
}
}
void Mle::RemoveDelayedDataResponseMessage(void)