Fix memory leak in wxXmlNode::operator=().
We must delete all children and attributes in the node being overwritten and not just the first one of each. Add a unit test exercising this code to be able to check that valgrind doesn't report memory leak any more after the fix. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73990 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,6 +91,18 @@ wxXmlNode::wxXmlNode(const wxXmlNode& node)
|
||||
}
|
||||
|
||||
wxXmlNode::~wxXmlNode()
|
||||
{
|
||||
DoFree();
|
||||
}
|
||||
|
||||
wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node)
|
||||
{
|
||||
DoFree();
|
||||
DoCopy(node);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxXmlNode::DoFree()
|
||||
{
|
||||
wxXmlNode *c, *c2;
|
||||
for (c = m_children; c; c = c2)
|
||||
@@ -107,14 +119,6 @@ wxXmlNode::~wxXmlNode()
|
||||
}
|
||||
}
|
||||
|
||||
wxXmlNode& wxXmlNode::operator=(const wxXmlNode& node)
|
||||
{
|
||||
wxDELETE(m_attrs);
|
||||
wxDELETE(m_children);
|
||||
DoCopy(node);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxXmlNode::DoCopy(const wxXmlNode& node)
|
||||
{
|
||||
m_type = node.m_type;
|
||||
|
||||
Reference in New Issue
Block a user