mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-09 23:33:17 +03:00
Fix memory leaks in toolcontext error path.
E.g. # vgscan Parse error at byte 2360 (line 54): expected a value Failed to load config file /etc/lvm/lvm.conf You have a memory leak (not released memory pool): [0x818c788] library (12 bytes) ...
This commit is contained in:
@@ -516,15 +516,15 @@ static void _destroy_tag_configs(struct cmd_context *cmd)
|
||||
{
|
||||
struct config_tree_list *cfl;
|
||||
|
||||
dm_list_iterate_items(cfl, &cmd->config_files) {
|
||||
destroy_config_tree(cfl->cft);
|
||||
}
|
||||
|
||||
if (cmd->cft && cmd->cft->root) {
|
||||
destroy_config_tree(cmd->cft);
|
||||
cmd->cft = NULL;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(cfl, &cmd->config_files) {
|
||||
destroy_config_tree(cfl->cft);
|
||||
}
|
||||
|
||||
dm_list_init(&cmd->config_files);
|
||||
}
|
||||
|
||||
@@ -1110,6 +1110,14 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
|
||||
return cmd;
|
||||
|
||||
error:
|
||||
_destroy_tag_configs(cmd);
|
||||
dev_cache_exit();
|
||||
if (cmd->filter)
|
||||
cmd->filter->destroy(cmd->filter);
|
||||
if (cmd->mem)
|
||||
dm_pool_destroy(cmd->mem);
|
||||
if (cmd->libmem)
|
||||
dm_pool_destroy(cmd->libmem);
|
||||
dm_free(cmd);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user