From ad67e8b47bfdc7890c750b3f36a4f25b7cd0ee46 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Thu, 3 Dec 2020 14:08:27 +0800 Subject: [PATCH] [udp6] initialize Socket variables in its constructor (#5902) --- src/core/net/udp6.cpp | 2 +- src/core/net/udp6.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/net/udp6.cpp b/src/core/net/udp6.cpp index 91b5e0e70..4c579a2bb 100644 --- a/src/core/net/udp6.cpp +++ b/src/core/net/udp6.cpp @@ -74,7 +74,7 @@ exit: Udp::Socket::Socket(Instance &aInstance) : InstanceLocator(aInstance) { - mHandle = nullptr; + Clear(); } Message *Udp::Socket::NewMessage(uint16_t aReserved, const Message::Settings &aSettings) diff --git a/src/core/net/udp6.hpp b/src/core/net/udp6.hpp index 9c1aecbf5..37cf6ff79 100644 --- a/src/core/net/udp6.hpp +++ b/src/core/net/udp6.hpp @@ -39,6 +39,7 @@ #include #include +#include "common/clearable.hpp" #include "common/linked_list.hpp" #include "common/locator.hpp" #include "common/non_copyable.hpp" @@ -70,7 +71,7 @@ public: * This class implements a UDP/IPv6 socket. * */ - class SocketHandle : public otUdpSocket, public LinkedListEntry + class SocketHandle : public otUdpSocket, public LinkedListEntry, public Clearable { friend class Udp; friend class LinkedList;