Sometimes I get a fail and sometimes I get a success. And the reason I get a fail is because of this:
Let's say the file is 100 bytes.
Memory:
buf: 0x00000000 [100 bytes of the contents of the file]
addr: 0x00000064 [random data in the memory]
By chance, I parsed another file right before this one and the [random data in the memory] looked like this: [<TagFromOldFile>...]. I traced through the Parse() function and it errored because it couldn't find the end tag, </TagFromOldFile>.
Is this a known bug that TinyXml will continue on with it's parsing, even after the top most tag has been matched with it's end tag?
Thanks,
Ted
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found this weird bug that occurs only sometimes and finally tracked it down.
Here's some code, which is pretty standard load file into memory and parse into tinyXml.
char* buf = LoadFile( filename );
TiXmlDocument xmlDoc;
xmlDoc.Parse( buf );
if ( xmlDoc.Error() )
{
// Parsing failed
return;
}
Sometimes I get a fail and sometimes I get a success. And the reason I get a fail is because of this:
Let's say the file is 100 bytes.
Memory:
buf: 0x00000000 [100 bytes of the contents of the file]
addr: 0x00000064 [random data in the memory]
By chance, I parsed another file right before this one and the [random data in the memory] looked like this: [<TagFromOldFile>...]. I traced through the Parse() function and it errored because it couldn't find the end tag, </TagFromOldFile>.
Is this a known bug that TinyXml will continue on with it's parsing, even after the top most tag has been matched with it's end tag?
Thanks,
Ted
I found the bug. The 100 bytes of contents of the file should be null terminated so buf's size should be 101 and buf[100] = '\0';
Thanks,
Ted