mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 22:27:47 +00:00
[ip6] fix message leak when using platform TCP (#6679)
When using platform TCP, `Ip6::HandlePayload()` will be called with `aIpProto = kProtoTcp` and `aMessageOwnerShip = kTakeCustody`. `FreeMessage()` will be called with `message = nullptr`, causing the message to leak. This commit fixes this issue.
This commit is contained in:
@@ -946,19 +946,13 @@ Error Ip6::HandlePayload(Message & aMessage,
|
||||
Message::Ownership aMessageOwnership)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Message *message = nullptr;
|
||||
Message *message = (aMessageOwnership == Message::kTakeCustody) ? &aMessage : nullptr;
|
||||
|
||||
VerifyOrExit(aIpProto == kProtoUdp || aIpProto == kProtoIcmp6);
|
||||
|
||||
switch (aMessageOwnership)
|
||||
if (aMessageOwnership == Message::kCopyToUse)
|
||||
{
|
||||
case Message::kTakeCustody:
|
||||
message = &aMessage;
|
||||
break;
|
||||
|
||||
case Message::kCopyToUse:
|
||||
VerifyOrExit((message = aMessage.Clone()) != nullptr, error = kErrorNoBufs);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (aIpProto)
|
||||
|
||||
Reference in New Issue
Block a user