From 7147cd9fe5584af05c0d0b4432326b2c6d7b754f Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 30 Apr 2010 12:37:04 +0000 Subject: [PATCH] Release pools for regex if there is error during processing (fixes error messages about unreleased pools). --- WHATS_NEW | 1 + lib/commands/toolcontext.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e15258acb..bac865ff5 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.64 - ================================= + Fix memory leak for invalid regex pattern input. Display invalid regex pattern for filter configuration in case of error. Remove no-longer-used arg_ptr_value. Fix -M and --type to use strings not pointers that change on config refresh. diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 20fd62e78..70f5231e5 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -639,14 +639,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd) else if (!(filters[nr_filt++] = regex_filter_create(cn->v))) { log_error("Failed to create regex device filter"); - return NULL; + goto err; } /* device type filter. Required. */ cn = find_config_tree_node(cmd, "devices/types"); if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) { log_error("Failed to create lvm type filter"); - return NULL; + goto err; } /* md component filter. Optional, non-critical. */ @@ -660,6 +660,11 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd) /* Only build a composite filter if we really need it. */ return (nr_filt == 1) ? filters[0] : composite_filter_create(nr_filt, filters); +err: + nr_filt--; /* skip NULL */ + while (nr_filt-- > 0) + filters[nr_filt]->destroy(filters[nr_filt]); + return NULL; } static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache) -- 2.43.5