Skip to content

Commit

Permalink
Fix LinkedList memory leak bug when elements are not owned. Thanks Pa…
Browse files Browse the repository at this point in the history
…ul Netherwood for reporting and fixing the bug
  • Loading branch information
dingmaotu committed Jun 20, 2018
1 parent 9824bae commit 0334e80
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Collection/LinkedList.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ public:
template<typename T>
LinkedListBase::~LinkedListBase()
{
if(m_owned)
LinkedNode<T>*n=m_head.next();
while(n!=m_tail)
{
LinkedNode<T>*n=m_head.next();
while(n!=m_tail)
{
LinkedNode<T>*tempNode=n.next();
SafeDelete(n);
n=tempNode;
}
LinkedNode<T>*tempNode=n.next();
if(!m_owned) n.release();
SafeDelete(n);
n=tempNode;
}

SafeDelete(m_head);
SafeDelete(m_tail);
}
Expand Down

0 comments on commit 0334e80

Please sign in to comment.