mirror of https://github.com/AxioDL/tinyxml2.git
Ensure existing attributes are not leaked on attribute insertion
This commit is contained in:
parent
156bc1b99f
commit
34a3f8e34d
|
@ -1717,9 +1717,11 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
|
||||||
attrib = CreateAttribute();
|
attrib = CreateAttribute();
|
||||||
TIXMLASSERT( attrib );
|
TIXMLASSERT( attrib );
|
||||||
if ( last ) {
|
if ( last ) {
|
||||||
|
TIXMLASSERT( last->_next == 0 );
|
||||||
last->_next = attrib;
|
last->_next = attrib;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
TIXMLASSERT( _rootAttribute == 0 );
|
||||||
_rootAttribute = attrib;
|
_rootAttribute = attrib;
|
||||||
}
|
}
|
||||||
attrib->SetName( name );
|
attrib->SetName( name );
|
||||||
|
@ -1777,9 +1779,11 @@ char* XMLElement::ParseAttributes( char* p )
|
||||||
// avoids re-scanning the attribute list. Preferring performance for
|
// avoids re-scanning the attribute list. Preferring performance for
|
||||||
// now, may reconsider in the future.
|
// now, may reconsider in the future.
|
||||||
if ( prevAttribute ) {
|
if ( prevAttribute ) {
|
||||||
|
TIXMLASSERT( prevAttribute->_next == 0 );
|
||||||
prevAttribute->_next = attrib;
|
prevAttribute->_next = attrib;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
TIXMLASSERT( _rootAttribute == 0 );
|
||||||
_rootAttribute = attrib;
|
_rootAttribute = attrib;
|
||||||
}
|
}
|
||||||
prevAttribute = attrib;
|
prevAttribute = attrib;
|
||||||
|
|
Loading…
Reference in New Issue