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.
This commit is contained in:
KimjeongYeon 2017-04-13 20:33:26 +02:00 committed by Georg Chini
parent ab7d01a983
commit 1f0c4f7d6a

View file

@ -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) { static void filter_free(struct filter *f) {
pa_assert(f); if (f) {
pa_xfree(f->name);
pa_xfree(f->name); pa_xfree(f);
pa_xfree(f); }
} }
static const char* should_filter(pa_object *o, bool is_sink_input) { 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: done:
pa_xfree(module_name); pa_xfree(module_name);
pa_xfree(fltr); filter_free(fltr);
return PA_HOOK_OK; return PA_HOOK_OK;
} }