From 7b6c89194c326abb286dae85de193debf2242826 Mon Sep 17 00:00:00 2001 From: Sean <97990350+s-mcclain@users.noreply.github.com> Date: Wed, 7 Sep 2022 09:01:11 -0500 Subject: [PATCH] Update UDPEndPointImplSockets.cpp Moved msg.IsNull check to beginning of SendMsgImpl --- src/inet/UDPEndPointImplSockets.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inet/UDPEndPointImplSockets.cpp b/src/inet/UDPEndPointImplSockets.cpp index eefcbb5e6c8dc8..282b7993301779 100644 --- a/src/inet/UDPEndPointImplSockets.cpp +++ b/src/inet/UDPEndPointImplSockets.cpp @@ -274,6 +274,9 @@ CHIP_ERROR UDPEndPointImplSockets::ListenImpl() CHIP_ERROR UDPEndPointImplSockets::SendMsgImpl(const IPPacketInfo * aPktInfo, System::PacketBufferHandle && msg) { + // Ensure packet buffer is not null + VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_NO_MEMORY); + // Make sure we have the appropriate type of socket based on the // destination address. ReturnErrorOnFailure(GetSocket(aPktInfo->DestAddress.Type())); @@ -281,9 +284,6 @@ CHIP_ERROR UDPEndPointImplSockets::SendMsgImpl(const IPPacketInfo * aPktInfo, Sy // Ensure the destination address type is compatible with the endpoint address type. VerifyOrReturnError(mAddrType == aPktInfo->DestAddress.Type(), CHIP_ERROR_INVALID_ARGUMENT); - // Ensure packet buffer is not null - VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_NO_MEMORY); - // For now the entire message must fit within a single buffer. VerifyOrReturnError(!msg->HasChainedBuffer(), CHIP_ERROR_MESSAGE_TOO_LONG);