Przeglądaj źródła

Merge pull request #504 from Dmitry-Me/ensureLinkPointersAreNotOverwritten

Ensure existing attributes are not leaked on attribute insertion
Lee Thomason 9 lat temu
rodzic
commit
5b733ff481
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      tinyxml2.cpp

+ 4 - 0
tinyxml2.cpp

@@ -1731,9 +1731,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 );
@@ -1794,9 +1796,11 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
             // 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;