Skip to content

Commit

Permalink
[asan][aclorch] fix a memory leak in the SaiAttrWrapper::swap() (#2382)
Browse files Browse the repository at this point in the history
* fix a leak caused by overriding this->m_attr (which contained a dynamically allocated list) in the SaiAttrWrapper::swap()
  • Loading branch information
Yakiv-Huryk authored Aug 9, 2022
1 parent 9f2e27b commit d36c17d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions orchagent/saiattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ sai_attr_id_t SaiAttrWrapper::getAttrId() const

void SaiAttrWrapper::swap(SaiAttrWrapper&& other)
{
m_objectType = other.m_objectType;
m_meta = other.m_meta;
m_attr = other.m_attr;
m_serializedAttr = other.m_serializedAttr;
other.m_attr = sai_attribute_t{};
other.m_serializedAttr.clear();
std::swap(m_objectType, other.m_objectType);
std::swap(m_meta, other.m_meta);
std::swap(m_attr, other.m_attr);
std::swap(m_serializedAttr, other.m_serializedAttr);
}

void SaiAttrWrapper::init(
Expand Down

0 comments on commit d36c17d

Please sign in to comment.