From 1920dde717fb7ef3be9da5c2774a97230c62497d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 10 Mar 2016 21:54:53 +0100 Subject: [PATCH] memory leak: at_keys had no dtor --- src/attributes/key.c | 6 +++++- src/tests.c | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/attributes/key.c b/src/attributes/key.c index 2d43df504..3df55174d 100644 --- a/src/attributes/key.c +++ b/src/attributes/key.c @@ -53,10 +53,14 @@ static int a_readkey(attrib *a, void *owner, struct gamedata *data) { return (res != AT_READ_FAIL) ? AT_READ_DEPR : res; } +static void a_freekeys(attrib *a) { + free(a->data.v); +} + attrib_type at_keys = { "keys", NULL, - NULL, + a_freekeys, NULL, a_writekeys, a_readkeys, diff --git a/src/tests.c b/src/tests.c index 69d4d4f2b..f8a0c2a7f 100644 --- a/src/tests.c +++ b/src/tests.c @@ -154,11 +154,13 @@ ship_type * test_create_shiptype(const char * name) stype->construction->skill = SK_SHIPBUILDING; } + if (stype->coasts) { + free(stype->coasts); + } stype->coasts = - (terrain_type **)malloc(sizeof(terrain_type *)*2); + (terrain_type **)malloc(sizeof(terrain_type *) * 2); stype->coasts[0] = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | SAIL_INTO | FLY_INTO); stype->coasts[1] = NULL; - if (default_locale) { locale_setstring(default_locale, name, name); }