From 860f4eb744af463dd4a0e7d11e7882973ccf1e44 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 28 Aug 2015 02:45:20 +0200 Subject: Fixed some memory leaks in code using libconfig - Special thanks to Dastgir Signed-off-by: Haru --- src/common/HPM.c | 2 +- src/map/battleground.c | 2 +- src/map/channel.c | 2 +- src/map/clif.c | 4 ++-- src/map/map.c | 4 ++-- src/map/quest.c | 1 + src/map/script.c | 1 + 7 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/common/HPM.c b/src/common/HPM.c index a78f03daa..6d68d6ed6 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -580,8 +580,8 @@ void hplugins_config_read(void) { snprintf(filename, 60, "plugins/%s%s", libconfig->setting_get_string_elem(plist,i), DLL_EXT); HPM->load(filename); } - libconfig->destroy(&plugins_conf); } + libconfig->destroy(&plugins_conf); if( HPM->plugin_count ) ShowStatus("HPM: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded, type '"CL_WHITE"plugins"CL_RESET"' to list them\n", HPM->plugin_count); diff --git a/src/map/battleground.c b/src/map/battleground.c index 915ccc851..19360cd97 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -457,8 +457,8 @@ void bg_config_read(void) { } bg->arenas = arena_count; } - libconfig->destroy(&bg_conf); } + libconfig->destroy(&bg_conf); } struct bg_arena *bg_name2arena (char *name) { int i; diff --git a/src/map/channel.c b/src/map/channel.c index 337d05504..6e15d072e 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -770,8 +770,8 @@ void read_channels_config(void) } ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(channel->db), config_filename); - libconfig->destroy(&channels_conf); } + libconfig->destroy(&channels_conf); } /*========================================== diff --git a/src/map/clif.c b/src/map/clif.c index 12565de3c..ac1052c71 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -17101,8 +17101,8 @@ void clif_cashshop_db(void) { } } - libconfig->destroy(&cashshop_conf); } + libconfig->destroy(&cashshop_conf); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename); } /// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE). @@ -18092,8 +18092,8 @@ bool clif_parse_roulette_db(void) { } } - libconfig->destroy(&roulette_conf); } + libconfig->destroy(&roulette_conf); for(i = 0; i < MAX_ROULETTE_LEVEL; i++) { int limit = MAX_ROULETTE_COLUMNS-i; diff --git a/src/map/map.c b/src/map/map.c index a7b171ddf..6e35e6bb6 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5273,8 +5273,6 @@ void read_map_zone_db(void) { } ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' zones in '"CL_WHITE"%s"CL_RESET"'.\n", zone_count, config_filename); - /* not supposed to go in here but in skill_final whatever */ - libconfig->destroy(&map_zone_db); /* post-load processing */ if( (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) ) @@ -5284,6 +5282,8 @@ void read_map_zone_db(void) { if( (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) ) zone->info.special = 1; } + /* not supposed to go in here but in skill_final whatever */ + libconfig->destroy(&map_zone_db); } int map_get_new_bonus_id (void) { diff --git a/src/map/quest.c b/src/map/quest.c index ddbd2f92d..fe4014ae5 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -529,6 +529,7 @@ int quest_read_db(void) count++; } + libconfig->destroy(&quest_db_conf); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, filename); return count; } diff --git a/src/map/script.c b/src/map/script.c index 3e6fb2c47..dc0edcb01 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -4719,6 +4719,7 @@ void script_load_translations(void) { script->load_translation(translation_file, ++lang_id, &total); } + libconfig->destroy(&translations_conf); if( total ) { DBIterator *main_iter; -- cgit v1.2.3-60-g2f50