diff --git a/src/kernel/building.c b/src/kernel/building.c index 3f3bf8ec1..b1a2915f9 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -94,7 +94,10 @@ void bt_register(building_type * type) void free_buildingtype(void *ptr) { building_type *btype = (building_type *)ptr; - free(btype->construction); + if (btype->construction) { + free(btype->construction->materials); + free(btype->construction); + } free(btype->_name); free(btype); } diff --git a/src/kernel/ship.c b/src/kernel/ship.c index a2b7c556e..6eb6116eb 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -245,7 +245,10 @@ static void free_shiptype(void *ptr) { ship_type *stype = (ship_type *)ptr; free(stype->_name); free(stype->coasts); - free(stype->construction); + if (stype->construction) { + free(stype->construction->materials); + free(stype->construction); + } free(stype); }