tinyxml2 icon indicating copy to clipboard operation
tinyxml2 copied to clipboard

Why LoadFile dont't check parse error?

Open dinghao188 opened this issue 3 years ago • 1 comments

The source code like:

XMLError XMLDocument::LoadFile( FILE* fp )
{
    Clear();
    // .... ....
    Parse();
    // so why don't check error here
    return _errorID;
}

but in another parse function:

XMLError XMLDocument::Parse( const char* p, size_t len )
{
    Clear();
    // ... ...
    Parse();
    // here check errors and do some cleaning
    if ( Error() ) {
        // clean up now essentially dangling memory.
        // and the parse fail can put objects in the
        // pools that are dead and inaccessible.
        DeleteChildren();
        _elementPool.Clear();
        _attributePool.Clear();
        _textPool.Clear();
        _commentPool.Clear();
    }
    return _errorID;
}

Does anyone knows the secrets? Thanks!

dinghao188 avatar Sep 08 '21 06:09 dinghao188

I wonder the same thing

valaxkong avatar Jun 29 '23 10:06 valaxkong