From 1f0c4f7d6af250e1d8dbb020de0f83afcec858b0 Mon Sep 17 00:00:00 2001 From: KimjeongYeon Date: Thu, 13 Apr 2017 20:33:26 +0200 Subject: [PATCH] filter-apply: Fix memory leak in process() fltr->name should be freed before freeing fltr. Because filter_free() can never be called from other places without f set, the pa_assert() can be removed and filter_free() can be used in process() as well. --- src/modules/module-filter-apply.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c index 364d68be7..193b2ce21 100644 --- a/src/modules/module-filter-apply.c +++ b/src/modules/module-filter-apply.c @@ -114,10 +114,10 @@ static struct filter *filter_new(const char *name, pa_sink *sink, pa_source *sou } static void filter_free(struct filter *f) { - pa_assert(f); - - pa_xfree(f->name); - pa_xfree(f); + if (f) { + pa_xfree(f->name); + pa_xfree(f); + } } static const char* should_filter(pa_object *o, bool is_sink_input) { @@ -506,7 +506,7 @@ static pa_hook_result_t process(struct userdata *u, pa_object *o, bool is_sink_i done: pa_xfree(module_name); - pa_xfree(fltr); + filter_free(fltr); return PA_HOOK_OK; }