CCSAXParser::parse issue?

I was loading a big sprite sheet and needed to increase my memsize, but then I got a whole different problem.
After some work I found this out this method which is called in the process:

@
bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength)
{
tinyxml2::XMLDocument tinyDoc;
tinyDoc.Parse(pXMLData);
XmlSaxHander printer;
printer.setCCSAXParserImp(this);

return tinyDoc.Accept( &printer );
}
@

tinyDoc.Parse(pXMLData):
Receives a length or, a default of –1 and does strlen on pXMLData.
When I was loading my big sprite sheet CCSAXParser::parse was called with uDataLength of 3000 or so (don’t really remember),
but the length received inside tinyDoc.Parse was over 200,000 which when used in memcpy made my program crashed.

My solution was to send uDataLength to tinyDocParse aswell.

But is it a good solution or something else is wrong here?

Hello, Tomer O

I registered on this forum to report the same bug, but found your message.
I encountered the same bug in pretty the same situtation and did the same fix.
Just added the second parameter to tinyDoc.Parse(pXMLData, uDataLength); call in CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) method.

Everything works now like a charm.

I don’t think this will cause some other problems, but I am also waiting for a confirmation from cocos2d-x team.

Its good to know I am not alone :slight_smile:

I only want confirmation from the cocos2d-x team and to be sure that in the next version this bug is fixed =]

Okay, I found this is fixed the same way in the latest cocos2d-x (2.1.3)

Nice, thanks.

May I say this is a really stupid bug XD