fixed a crash

This commit is contained in:
Enno Rehling 2015-10-14 22:06:40 +02:00
parent 3200dd2dc8
commit ef1a2dfc4f

View file

@ -255,22 +255,27 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
return data; return data;
} }
static void free_localedata(int lindex) { static void clear_localedata(int lindex) {
int i; int i;
for (i = 0; i != MAXKEYWORDS; ++i) { for (i = 0; i != MAXKEYWORDS; ++i) {
release_data(locale_array[lindex]->short_orders[i]); release_data(locale_array[lindex]->short_orders[i]);
locale_array[lindex]->short_orders[i] = 0;
} }
for (i = 0; i != MAXSKILLS; ++i) { for (i = 0; i != MAXSKILLS; ++i) {
release_data(locale_array[lindex]->study_orders[i]); release_data(locale_array[lindex]->study_orders[i]);
locale_array[lindex]->study_orders[i] = 0;
} }
free(locale_array[lindex]); locale_array[lindex]->lang = 0;
locale_array[lindex] = 0;
} }
void close_orders(void) { void close_orders(void) {
int i; int i;
for (i = 0; i != MAXLOCALES; ++i) { for (i = 0; i != MAXLOCALES; ++i) {
if (locale_array[i]) free_localedata(i); if (locale_array[i]){
clear_localedata(i);
free(locale_array[i]);
locale_array[i] = 0;
}
} }
} }
@ -302,7 +307,7 @@ static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent,
locale_array[lindex] = (locale_data *)calloc(1, sizeof(locale_data)); locale_array[lindex] = (locale_data *)calloc(1, sizeof(locale_data));
} }
else if (locale_array[lindex]->lang != lang) { else if (locale_array[lindex]->lang != lang) {
free_localedata(lindex); clear_localedata(lindex);
} }
locale_array[lindex]->lang = lang; locale_array[lindex]->lang = lang;