From a98b60ef2ed025ee4c0da06495b2d40e3926eb78 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 14 Jun 2024 10:00:58 -0700 Subject: [PATCH] [udp] clear all properties in `SocketHandle` from `Udp::Open()` (#10380) This commit modifies `Udp::Open()` to clear all properties of the passed-in `aSocket` using the `Clear()` method. This replaces the existing code, which only cleared the socket and peer address and port numbers. This change ensures that `void *mHandle` member variable in `otUdpSocket` is also set to `nullptr` before invoking platform UDP `otPlatUdpSocket()`. --- src/core/net/udp6.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/net/udp6.cpp b/src/core/net/udp6.cpp index bb24e5030..05ba27bc9 100644 --- a/src/core/net/udp6.cpp +++ b/src/core/net/udp6.cpp @@ -175,8 +175,7 @@ Error Udp::Open(SocketHandle &aSocket, otUdpReceive aHandler, void *aContext) OT_ASSERT(!IsOpen(aSocket)); - aSocket.GetSockName().Clear(); - aSocket.GetPeerName().Clear(); + aSocket.Clear(); aSocket.mHandler = aHandler; aSocket.mContext = aContext;