Skip to content

Commit d36c17d

Browse files
authored
[asan][aclorch] fix a memory leak in the SaiAttrWrapper::swap() (sonic-net#2382)
* fix a leak caused by overriding this->m_attr (which contained a dynamically allocated list) in the SaiAttrWrapper::swap()
1 parent 9f2e27b commit d36c17d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

orchagent/saiattr.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,10 @@ sai_attr_id_t SaiAttrWrapper::getAttrId() const
6666

6767
void SaiAttrWrapper::swap(SaiAttrWrapper&& other)
6868
{
69-
m_objectType = other.m_objectType;
70-
m_meta = other.m_meta;
71-
m_attr = other.m_attr;
72-
m_serializedAttr = other.m_serializedAttr;
73-
other.m_attr = sai_attribute_t{};
74-
other.m_serializedAttr.clear();
69+
std::swap(m_objectType, other.m_objectType);
70+
std::swap(m_meta, other.m_meta);
71+
std::swap(m_attr, other.m_attr);
72+
std::swap(m_serializedAttr, other.m_serializedAttr);
7573
}
7674

7775
void SaiAttrWrapper::init(

0 commit comments

Comments
 (0)