Skip to content

Commit

Permalink
[PacketBufferHandle::IsNull] Missing null check after calling PacketB…
Browse files Browse the repository at this point in the history
…ufferHandle::CloneData in UserDirectedCommissioningClient (project-chip#25521)
  • Loading branch information
vivien-apple authored and David Lechner committed Mar 22, 2023
1 parent 1725dc5 commit 0e28d88
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,27 @@ namespace UserDirectedCommissioning {
CHIP_ERROR UserDirectedCommissioningClient::SendUDCMessage(TransportMgrBase * transportMgr, System::PacketBufferHandle && payload,
chip::Transport::PeerAddress peerAddress)
{
CHIP_ERROR err = EncodeUDCMessage(payload);
if (err != CHIP_NO_ERROR)
{
return err;
}
ReturnErrorOnFailure(EncodeUDCMessage(payload));

ChipLogProgress(Inet, "Sending UDC msg");

// send UDC message 5 times per spec (no ACK on this message)
for (unsigned int i = 0; i < 5; i++)
{
err = transportMgr->SendMessage(peerAddress, payload.CloneData());
auto msgCopy = payload.CloneData();
VerifyOrReturnError(!msgCopy.IsNull(), CHIP_ERROR_NO_MEMORY);

auto err = transportMgr->SendMessage(peerAddress, std::move(msgCopy));
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "UDC SendMessage failed: %" CHIP_ERROR_FORMAT, err.Format());
return err;
}
sleep(1);
}
ChipLogProgress(Inet, "UDC msg send status %" CHIP_ERROR_FORMAT, err.Format());
return err;

ChipLogProgress(Inet, "UDC msg sent");
return CHIP_NO_ERROR;
}

CHIP_ERROR UserDirectedCommissioningClient::EncodeUDCMessage(const System::PacketBufferHandle & payload)
Expand Down

0 comments on commit 0e28d88

Please sign in to comment.