while(!m_RemoveNodeList.empty())
{
list<CNode *>::const_iterator const it = m_RemoveNodeList.begin();
CNode * const pNode = *it;
ASSERT(pNode != NULL);
m_NodeList.remove( pNode );
delete pNode; // crashing here
m_RemoveNodeList.pop_front();
}
The above sometimes crashes at the delete with a read violation exception. could i be that i accidentally double delete?
both m_NodeList and m_RemoveNodeList are of type
std::list<CNode *>
i should mention that CNode is a base class for several other classes. however none of those classes does anything in their destructors
There is no apparent crash in your code and looks fine.
It could crash only if there are duplicate
CNode*are stored inside thelist<CNode*>; which will lead you to multipledelete. (it’s mentioned by @pau.estalella in the comments).You can try following method to catch if there are duplicate
CNode*.