Menu

#6 Crashes binding an empty node in <EMPTY /> from

open
nobody
None
5
2008-05-16
2008-05-16
Anonymous
No

Calling BindFromXml works find for empty nodes of the form <EMPTY></EMPTY>.
When reading such a form from a file TinyXML converts it to <EMPTY />. Calling BindFromXml on an TiXmlElement based on this form will crash in GenericTiXmlBinding::fromXml because node == NULL.
My fix (not sure if its the best but it seems to work) is to test this case and return true.
So existing code:
TiXmlNode * node = elem.FirstChild();
TiXmlText * nodedata = node->ToText();
ConvertFromString( nodedata->Value(), data );
return true;

Becomes:
TiXmlNode * node = elem.FirstChild();
if (node==NULL)
return true; // Empty node eg <EMPTY />.
TiXmlText * nodedata = node->ToText();
ConvertFromString( nodedata->Value(), data );
return true;

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.