coverity scan CID 22516: out-of-bounds write

potentially a bug with bad XML files? only matters if we have those, but we shouldn't
This commit is contained in:
Enno Rehling 2015-10-29 09:49:26 +01:00
parent 8b92003fff
commit 2372d3aacd
1 changed files with 15 additions and 12 deletions

View File

@ -1815,6 +1815,7 @@ static int parse_races(xmlDocPtr doc)
if (result->nodesetval->nodeNr > MAXMAGIETYP) {
log_error("race %s has %d potential familiars", rc->_name, result->nodesetval->nodeNr);
}
else {
for (k = 0; k != MAXMAGIETYP; ++k) {
if (k < result->nodesetval->nodeNr) {
xmlNodePtr node = result->nodesetval->nodeTab[k];
@ -1830,10 +1831,12 @@ static int parse_races(xmlDocPtr doc)
rc->familiars[k] = frc;
}
xmlFree(propValue);
} else {
}
else {
rc->familiars[k] = frc;
}
}
}
xmlXPathFreeObject(result);
/* reading eressea/races/race/precombatspell */