fix the xmlreader to not assert on invalid data

This commit is contained in:
Enno Rehling 2012-05-23 21:06:19 -07:00
parent 92e96689bb
commit 9b3234a067
1 changed files with 8 additions and 4 deletions

View File

@ -1481,9 +1481,13 @@ static int parse_spellbooks(xmlDocPtr doc)
spellbook * sb;
propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL);
sb = get_spellbook((const char *)propValue);
xmlFree(propValue);
if (propValue) {
sb = get_spellbook((const char *)propValue);
xmlFree(propValue);
} else {
log_error("spellbook at index '%d' has n name\n", i);
continue;
}
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "entry", xpath);
@ -1494,7 +1498,7 @@ static int parse_spellbooks(xmlDocPtr doc)
spell * sp = 0;
int level = xml_ivalue(node, "level", -1);
propValue = xmlGetProp(node, BAD_CAST "name");
propValue = xmlGetProp(node, BAD_CAST "spell");
if (propValue) {
sp = find_spell((const char *)propValue);
xmlFree(propValue);