From 8ffa0919366a631e9189ee9a84c562de3b8a5d4f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 6 Feb 2017 20:34:11 +0100 Subject: [PATCH] do not abort xml parsing when there is no calendar --- src/kernel/xmlreader.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 00bb9f848..cd3331517 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -358,16 +358,13 @@ static int parse_calendar(xmlDocPtr doc) xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr xpathCalendars; xmlNodeSetPtr nsetCalendars; - int c, rv = 0; /* reading eressea/buildings/building */ xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); nsetCalendars = xpathCalendars->nodesetval; months_per_year = 0; - if (nsetCalendars == NULL || nsetCalendars->nodeNr == 0) { - rv = -1; - } - else + if (nsetCalendars != NULL && nsetCalendars->nodeNr != 0) { + int c; for (c = 0; c != nsetCalendars->nodeNr; ++c) { xmlNodePtr calendar = nsetCalendars->nodeTab[c]; xmlXPathObjectPtr xpathWeeks, xpathMonths, xpathSeasons; @@ -477,10 +474,11 @@ static int parse_calendar(xmlDocPtr doc) xmlFree(newyear); newyear = NULL; } + } xmlXPathFreeObject(xpathCalendars); xmlXPathFreeContext(xpath); - return rv; + return 0; } static int parse_ships(xmlDocPtr doc)