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,10 +761,10 @@ 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) {
char * tok = strtok((char *)propValue, " ,");
while (tok) { while (tok) {
race * rc = rc_get_or_create(tok); race * rc = rc_get_or_create(tok);
if (!rc->mask_item) { if (!rc->mask_item) {
@ -774,8 +774,9 @@ static void mask_races(xmlNodePtr node, const char *key, int *maskp) {
mask |= rc->mask_item; mask |= rc->mask_item;
tok = strtok(NULL, " ,"); tok = strtok(NULL, " ,");
} }
*maskp = mask;
xmlFree(propValue); xmlFree(propValue);
}
*maskp = mask;
} }
static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype)