fix a segfault in free_Races

This commit is contained in:
Enno Rehling 2017-02-07 21:37:38 +01:00
parent 60497da87b
commit f48dd41538
3 changed files with 9 additions and 3 deletions

View File

@ -203,7 +203,7 @@ param_t findparam(const char *s, const struct locale * lang)
void **tokens = get_translations(lang, UT_PARAMS);
critbit_tree *cb = (critbit_tree *)*tokens;
if (!cb) {
log_warning("no parameters defined in locale %s", locale_name(lang));
log_error("no parameters defined in locale %s", locale_name(lang));
}
else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
cb_get_kv(match, &i, sizeof(int));

View File

@ -269,7 +269,13 @@ void free_races(void) {
free(opt);
}
for (i = 0; races->attack[i].type!=AT_NONE; ++i) {
spellref_free(races->attack[i].data.sp);
att *at = races->attack + i;
if (at->type == AT_SPELL) {
spellref_free(at->data.sp);
}
else {
free(at->data.dice);
}
}
spellref_free(races->precombatspell);
free(xrefs);

View File

@ -105,7 +105,7 @@ extern "C" {
typedef struct att {
int type;
union {
const char *dice;
char *dice;
struct spellref *sp;
} data;
int flags;