From c50c8d2be94bc8660cfa85d38e96dc7f1157c62c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 11 May 2021 09:47:25 +0200 Subject: [PATCH] modules: fix some leaks in error paths As found by coverity --- src/modules/module-filter-chain.c | 10 +++++----- .../modules/module-ladspa-sink.c | 15 ++++++++------- .../modules/module-ladspa-source.c | 15 ++++++++------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index bdc8df29e..c110854b0 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -949,17 +949,17 @@ static int parse_link(struct graph *graph, struct spa_json *json) return -ENOENT; } + if (in_port->n_links > 0) { + pw_log_info("Can't have more than 1 link to %s, use a mixer", input); + return -ENOTSUP; + } + if ((link = calloc(1, sizeof(*link))) == NULL) return -errno; link->output = out_port; link->input = in_port; - if (in_port->n_links > 0) { - pw_log_info("Can't have more than 1 link to %s, use a mixer", input); - return -ENOTSUP; - } - pw_log_info("linking %s:%s -> %s:%s", out_port->node->name, out_port->node->desc->desc->PortNames[out_port->p], diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c index d2fb5666e..7a8f9d970 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-sink.c @@ -88,9 +88,14 @@ static int module_ladspa_sink_load(struct client *client, struct module *module) struct module_ladspa_sink_data *data = module->user_data; FILE *f; char *args; - const char *str; + const char *str, *plugin, *label; size_t size; + if ((plugin = pw_properties_get(module->props, "plugin")) == NULL) + return -EINVAL; + if ((label = pw_properties_get(module->props, "label")) == NULL) + return -EINVAL; + pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "ladspa-sink-%u", module->idx); pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "ladspa-sink-%u", module->idx); @@ -100,12 +105,8 @@ static int module_ladspa_sink_load(struct client *client, struct module *module) fprintf(f, " filter.graph = {"); fprintf(f, " nodes = [ { "); fprintf(f, " type = ladspa "); - if ((str = pw_properties_get(module->props, "plugin")) == NULL) - return -EINVAL; - fprintf(f, " plugin = \"%s\" ", str); - if ((str = pw_properties_get(module->props, "label")) == NULL) - return -EINVAL; - fprintf(f, " label = \"%s\" ", str); + fprintf(f, " plugin = \"%s\" ", plugin); + fprintf(f, " label = \"%s\" ", label); if ((str = pw_properties_get(module->props, "inputs")) != NULL) fprintf(f, " inputs = [ %s ] ", str); if ((str = pw_properties_get(module->props, "outputs")) != NULL) diff --git a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c index d081af3b9..ea4065650 100644 --- a/src/modules/module-protocol-pulse/modules/module-ladspa-source.c +++ b/src/modules/module-protocol-pulse/modules/module-ladspa-source.c @@ -88,9 +88,14 @@ static int module_ladspa_source_load(struct client *client, struct module *modul struct module_ladspa_source_data *data = module->user_data; FILE *f; char *args; - const char *str; + const char *str, *plugin, *label; size_t size; + if ((plugin = pw_properties_get(module->props, "plugin")) == NULL) + return -EINVAL; + if ((label = pw_properties_get(module->props, "label")) == NULL) + return -EINVAL; + pw_properties_setf(data->capture_props, PW_KEY_NODE_GROUP, "ladspa-source-%u", module->idx); pw_properties_setf(data->playback_props, PW_KEY_NODE_GROUP, "ladspa-source-%u", module->idx); @@ -100,12 +105,8 @@ static int module_ladspa_source_load(struct client *client, struct module *modul fprintf(f, " filter.graph = {"); fprintf(f, " nodes = [ { "); fprintf(f, " type = ladspa "); - if ((str = pw_properties_get(module->props, "plugin")) == NULL) - return -EINVAL; - fprintf(f, " plugin = \"%s\" ", str); - if ((str = pw_properties_get(module->props, "label")) == NULL) - return -EINVAL; - fprintf(f, " label = \"%s\" ", str); + fprintf(f, " plugin = \"%s\" ", plugin); + fprintf(f, " label = \"%s\" ", label); if ((str = pw_properties_get(module->props, "inputs")) != NULL) fprintf(f, " inputs = [ %s ] ", str); if ((str = pw_properties_get(module->props, "outputs")) != NULL)