XMLDoc_parse_file_DOM do not return false after finding ERROR
Simple, lightweight XML parser in C, statically or dynamically linked.
Brought to you by:
matthieu-labas
I use test.xml file:
<FATHER>
<x>
</FATHER>
after parse using XMLDoc_parse_file_DOM I received 'Segmentation fault'
(program do not ends becouse XMLDoc_parse_file_DOM don't return false after finding parse ERROR)
alex@debian7:~/xml/test_sxmlc_7$ ./test.out
test.xml:3: ERROR - End tag </FATHER> was unexpected (</x> was expected)
test.xml:3: An error was found (UNEXPECTED_NODE_END), loading aborted...
Start search 'st*[@name="st*sub*", @valid!="false"]/property[@name="t?t?"]'
Segmentation fault
to correct this I made chcenge in source code ( function: '_parse_data_SAX'', file: 'sxmlc.c')
from:
case TAG_END:
if (sax->end_node != NULL || sax->all_event != NULL) {
if (sax->end_node != NULL && (exit = !sax->end_node(&node, sd)))
break;
if (sax->all_event != NULL && (exit = !sax->all_event(XML_EVENT_END_NODE, &node, NULL, sd->line_num, sd)))
break;
}
break;
to:
case TAG_END:
if (sax->end_node != NULL || sax->all_event != NULL) {
if (sax->end_node != NULL && (exit = !sax->end_node(&node, sd))) {
ret = false;
break;
}
if (sax->all_event != NULL && (exit = !sax->all_event(XML_EVENT_END_NODE, &node, NULL, sd->line_num, sd)))
break;
}
break;
Behaviour was changed so that
0is returned on parsing when a SAX callback returns0.