tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

fix assertion

Open dinghao188 opened this issue 4 years ago • 4 comments

Assertion '_elementPool.CurrentAllocs() == _elementPool.Untracked()' failed.

dinghao188 avatar Sep 17 '21 02:09 dinghao188

The description doesn't seem to match the change. What's the intended change for this PR?

leethomason avatar Apr 02 '22 20:04 leethomason

there is a code block

#ifdef TINYXML2_DEBUG
    if ( !hadError ) {
        TIXMLASSERT( _elementPool.CurrentAllocs()   == _elementPool.Untracked() );
        TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
        TIXMLASSERT( _textPool.CurrentAllocs()      == _textPool.Untracked() );
        TIXMLASSERT( _commentPool.CurrentAllocs()   == _commentPool.Untracked() );
    }

#endif

i compile the code with TINYXML2_DEBUG=ON, and i use one XMLDocument object to parse several files, for example one.xml, two.xml and three.xml. if one.xml is wrong-format and two.xml is right-format, it will assert failed at that block while parsing three.xml.

dinghao188 avatar Apr 02 '22 20:04 dinghao188

I see, I think. That code does look suspect.

  • Did you mean to provide "resources/xmltest-5330.xml?
  • Why did you remove the "file doesn't exist" test, instead of just adding a new one?

leethomason avatar Apr 02 '22 21:04 leethomason

I added a new one, pls help to check, i have tested for it.

dinghao188 avatar Apr 02 '22 22:04 dinghao188