do not leak terrain.herbs

This commit is contained in:
Enno Rehling 2015-10-14 21:37:27 +02:00
parent c04bda102b
commit b5455531e7
2 changed files with 2 additions and 0 deletions

View File

@ -270,6 +270,7 @@ static void json_terrain(cJSON *json, terrain_type *ter) {
int size = cJSON_GetArraySize(child); int size = cJSON_GetArraySize(child);
if (size > 0) { if (size > 0) {
int n; int n;
free(ter->herbs);
ter->herbs = malloc(sizeof(const item_type *) * (size + 1)); ter->herbs = malloc(sizeof(const item_type *) * (size + 1));
ter->herbs[size] = 0; ter->herbs[size] = 0;
for (n = 0, entry = child->child; entry; entry = entry->next) { for (n = 0, entry = child->child; entry; entry = entry->next) {

View File

@ -63,6 +63,7 @@ void free_terrains(void)
terrain_type * t = registered_terrains; terrain_type * t = registered_terrains;
registered_terrains = t->next; registered_terrains = t->next;
free(t->_name); free(t->_name);
free(t->herbs);
if (t->production) { if (t->production) {
for (n = 0; t->production[n].type; ++n) { for (n = 0; t->production[n].type; ++n) {
free(t->production[n].base); free(t->production[n].base);