mirror of https://github.com/AxioDL/tinyxml2.git
fix double delete in xml element
This commit is contained in:
parent
6ee99fc344
commit
d923c670fc
38
tinyxml2.cpp
38
tinyxml2.cpp
|
@ -188,18 +188,30 @@ XMLNode::XMLNode( XMLDocument* doc ) :
|
||||||
|
|
||||||
XMLNode::~XMLNode()
|
XMLNode::~XMLNode()
|
||||||
{
|
{
|
||||||
XMLNode* node=firstChild;
|
//printf( "~XMLNode %x\n", this );
|
||||||
while( node ) {
|
while( firstChild ) {
|
||||||
XMLNode* temp = node->next;
|
XMLNode* node = firstChild;
|
||||||
|
Unlink( node );
|
||||||
delete node;
|
delete node;
|
||||||
node = temp;
|
|
||||||
}
|
}
|
||||||
if ( prev ) {
|
}
|
||||||
prev->next = next;
|
|
||||||
|
|
||||||
|
void XMLNode::Unlink( XMLNode* child )
|
||||||
|
{
|
||||||
|
TIXMLASSERT( child->parent == this );
|
||||||
|
if ( child == firstChild )
|
||||||
|
firstChild = firstChild->next;
|
||||||
|
if ( child == lastChild )
|
||||||
|
lastChild = lastChild->prev;
|
||||||
|
|
||||||
|
if ( child->prev ) {
|
||||||
|
child->prev->next = child->next;
|
||||||
}
|
}
|
||||||
if ( next ) {
|
if ( child->next ) {
|
||||||
next->prev = prev;
|
child->next->prev = child->prev;
|
||||||
}
|
}
|
||||||
|
child->parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,6 +266,7 @@ XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc )
|
||||||
|
|
||||||
XMLComment::~XMLComment()
|
XMLComment::~XMLComment()
|
||||||
{
|
{
|
||||||
|
//printf( "~XMLComment\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,19 +312,14 @@ XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ),
|
||||||
|
|
||||||
XMLElement::~XMLElement()
|
XMLElement::~XMLElement()
|
||||||
{
|
{
|
||||||
|
//printf( "~XMLElemen %x\n",this );
|
||||||
|
|
||||||
XMLAttribute* attribute = rootAttribute;
|
XMLAttribute* attribute = rootAttribute;
|
||||||
while( attribute ) {
|
while( attribute ) {
|
||||||
XMLAttribute* next = attribute->next;
|
XMLAttribute* next = attribute->next;
|
||||||
delete attribute;
|
delete attribute;
|
||||||
attribute = next;
|
attribute = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLNode* child = firstChild;
|
|
||||||
while( child ) {
|
|
||||||
XMLNode* next = child->next;
|
|
||||||
delete child;
|
|
||||||
child = next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLNode( XMLDocument* );
|
XMLNode( XMLDocument* );
|
||||||
|
void Unlink( XMLNode* child );
|
||||||
|
|
||||||
XMLDocument* document;
|
XMLDocument* document;
|
||||||
XMLNode* parent;
|
XMLNode* parent;
|
||||||
|
|
BIN
tinyxml2.suo
BIN
tinyxml2.suo
Binary file not shown.
Loading…
Reference in New Issue