fix bad strtok call

This commit is contained in:
Enno Rehling 2017-03-03 10:35:34 +01:00
parent 6e8e163099
commit 5b1e786fb2
1 changed files with 11 additions and 10 deletions

View File

@ -761,21 +761,22 @@ static int race_mask = 1;
static void mask_races(xmlNodePtr node, const char *key, int *maskp) { static void mask_races(xmlNodePtr node, const char *key, int *maskp) {
xmlChar *propValue = xmlGetProp(node, BAD_CAST key); xmlChar *propValue = xmlGetProp(node, BAD_CAST key);
char *tok;
int mask = 0; int mask = 0;
assert(maskp); assert(maskp);
tok = strtok((char *)propValue, " ,"); if (propValue) {
while (tok) { char * tok = strtok((char *)propValue, " ,");
race * rc = rc_get_or_create(tok); while (tok) {
if (!rc->mask_item) { race * rc = rc_get_or_create(tok);
rc->mask_item = race_mask; if (!rc->mask_item) {
race_mask = race_mask << 1; rc->mask_item = race_mask;
race_mask = race_mask << 1;
}
mask |= rc->mask_item;
tok = strtok(NULL, " ,");
} }
mask |= rc->mask_item; xmlFree(propValue);
tok = strtok(NULL, " ,");
} }
*maskp = mask; *maskp = mask;
xmlFree(propValue);
} }
static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)