diff --git a/src/kernel/order.c b/src/kernel/order.c index 00d2a838d..f79b2dd68 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -255,22 +255,27 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex) return data; } -static void free_localedata(int lindex) { +static void clear_localedata(int lindex) { int i; for (i = 0; i != MAXKEYWORDS; ++i) { release_data(locale_array[lindex]->short_orders[i]); + locale_array[lindex]->short_orders[i] = 0; } for (i = 0; i != MAXSKILLS; ++i) { release_data(locale_array[lindex]->study_orders[i]); + locale_array[lindex]->study_orders[i] = 0; } - free(locale_array[lindex]); - locale_array[lindex] = 0; + locale_array[lindex]->lang = 0; } void close_orders(void) { int 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)); } else if (locale_array[lindex]->lang != lang) { - free_localedata(lindex); + clear_localedata(lindex); } locale_array[lindex]->lang = lang;