diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 7c07754d1..3c7faea6e 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -114,8 +114,8 @@ Mle::Mle(Instance &aInstance) { otMeshLocalPrefix meshLocalPrefix; - memset(&mLeaderData, 0, sizeof(mLeaderData)); - memset(&mParentLeaderData, 0, sizeof(mParentLeaderData)); + mLeaderData.Clear(); + mParentLeaderData.Clear(); mParent.Clear(); memset(&mChildIdRequest, 0, sizeof(mChildIdRequest)); mParentCandidate.Clear(); diff --git a/src/core/thread/mle_tlvs.hpp b/src/core/thread/mle_tlvs.hpp index e54582149..b69d985e3 100644 --- a/src/core/thread/mle_tlvs.hpp +++ b/src/core/thread/mle_tlvs.hpp @@ -976,6 +976,12 @@ OT_TOOL_PACKED_BEGIN class LeaderDataTlv : public Tlv { public: + /** + * This method clears the object (setting all fields to zero). + * + */ + void Clear(void) { memset(this, 0, sizeof(*this)); } + /** * This method initializes the TLV. *