From 34a3f8e34d6a6f9a26a3f8a159f8eb699b332725 Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Mon, 19 Dec 2016 12:05:21 +0300 Subject: [PATCH] Ensure existing attributes are not leaked on attribute insertion --- tinyxml2.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 96f3ad7..6fd9363 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1717,9 +1717,11 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) attrib = CreateAttribute(); TIXMLASSERT( attrib ); if ( last ) { + TIXMLASSERT( last->_next == 0 ); last->_next = attrib; } else { + TIXMLASSERT( _rootAttribute == 0 ); _rootAttribute = attrib; } attrib->SetName( name ); @@ -1777,9 +1779,11 @@ char* XMLElement::ParseAttributes( char* p ) // avoids re-scanning the attribute list. Preferring performance for // now, may reconsider in the future. if ( prevAttribute ) { + TIXMLASSERT( prevAttribute->_next == 0 ); prevAttribute->_next = attrib; } else { + TIXMLASSERT( _rootAttribute == 0 ); _rootAttribute = attrib; } prevAttribute = attrib;