Skip to content

Commit

Permalink
Fix a memory leak in TableData::operator= (#3807)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang authored Mar 21, 2024
1 parent a9b452a commit ae747cd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Src/Base/AMReX_TableData.H
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,17 @@ template <typename T, int N>
TableData<T,N>&
TableData<T,N>::operator= (TableData<T,N> && rhs) noexcept
{
m_arena = rhs.m_arena;
m_dptr = rhs.m_dptr;
m_lo = rhs.m_lo;
m_hi = rhs.m_hi;
m_truesize = rhs.m_truesize;
m_ptr_owner = rhs.m_ptr_owner;
rhs.m_dptr = nullptr;
rhs.m_ptr_owner = false;
if (this != &rhs) {
clear();
m_arena = rhs.m_arena;
m_dptr = rhs.m_dptr;
m_lo = rhs.m_lo;
m_hi = rhs.m_hi;
m_truesize = rhs.m_truesize;
m_ptr_owner = rhs.m_ptr_owner;
rhs.m_dptr = nullptr;
rhs.m_ptr_owner = false;
}
return *this;
}

Expand Down

0 comments on commit ae747cd

Please sign in to comment.