mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 20:27:47 +00:00
[coap] check error code on appending metadata (#3786)
This commit is contained in:
committed by
Jonathan Hui
parent
988be2a7f6
commit
f45f822800
+15
-6
@@ -746,18 +746,21 @@ exit:
|
||||
|
||||
void ResponsesQueue::EnqueueResponse(Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
Message * copy;
|
||||
otError error = OT_ERROR_NONE;
|
||||
Message * cachedResponse = NULL;
|
||||
Message * responseCopy = NULL;
|
||||
EnqueuedResponseHeader enqueuedResponseHeader(aMessageInfo);
|
||||
uint16_t messageCount;
|
||||
uint16_t bufferCount;
|
||||
|
||||
switch (GetMatchedResponseCopy(aMessage, aMessageInfo, ©))
|
||||
switch (GetMatchedResponseCopy(aMessage, aMessageInfo, &cachedResponse))
|
||||
{
|
||||
case OT_ERROR_NOT_FOUND:
|
||||
break;
|
||||
|
||||
case OT_ERROR_NONE:
|
||||
copy->Free();
|
||||
assert(cachedResponse != NULL);
|
||||
cachedResponse->Free();
|
||||
|
||||
// fall through
|
||||
|
||||
@@ -773,10 +776,10 @@ void ResponsesQueue::EnqueueResponse(Message &aMessage, const Ip6::MessageInfo &
|
||||
DequeueOldestResponse();
|
||||
}
|
||||
|
||||
VerifyOrExit((copy = aMessage.Clone()) != NULL);
|
||||
VerifyOrExit((responseCopy = aMessage.Clone()) != NULL);
|
||||
|
||||
enqueuedResponseHeader.AppendTo(*copy);
|
||||
mQueue.Enqueue(*copy);
|
||||
SuccessOrExit(error = enqueuedResponseHeader.AppendTo(*responseCopy));
|
||||
mQueue.Enqueue(*responseCopy);
|
||||
|
||||
if (!mTimer.IsRunning())
|
||||
{
|
||||
@@ -784,6 +787,12 @@ void ResponsesQueue::EnqueueResponse(Message &aMessage, const Ip6::MessageInfo &
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
if (error != OT_ERROR_NONE && responseCopy != NULL)
|
||||
{
|
||||
responseCopy->Free();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user