mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-05 06:46:28 -04:00
pipewire: fix some allocation errors
Also fix a string leak in the device error path.
This commit is contained in:
parent
ccfb61efa4
commit
3ef2b77915
5 changed files with 27 additions and 3 deletions
|
|
@ -331,6 +331,8 @@ static struct port *alloc_port(struct filter *filter,
|
|||
struct port *p;
|
||||
|
||||
p = calloc(1, sizeof(struct port) + user_data_size);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
p->filter = filter;
|
||||
p->direction = direction;
|
||||
p->latency[SPA_DIRECTION_INPUT] = SPA_LATENCY_INFO(SPA_DIRECTION_INPUT);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,10 @@ struct pw_impl_device *pw_context_create_device(struct pw_context *context,
|
|||
impl->cache_params = true;
|
||||
|
||||
this = &impl->this;
|
||||
this->name = strdup("device");
|
||||
if ((this->name = strdup("device")) == NULL) {
|
||||
res = -errno;
|
||||
goto error_free;
|
||||
}
|
||||
pw_log_debug("%p: new", this);
|
||||
|
||||
if (properties == NULL)
|
||||
|
|
@ -210,6 +213,7 @@ struct pw_impl_device *pw_context_create_device(struct pw_context *context,
|
|||
return this;
|
||||
|
||||
error_free:
|
||||
free(this->name);
|
||||
free(impl);
|
||||
error_cleanup:
|
||||
pw_properties_free(properties);
|
||||
|
|
|
|||
|
|
@ -1649,7 +1649,10 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context,
|
|||
|
||||
this = &impl->this;
|
||||
this->context = context;
|
||||
this->name = strdup("node");
|
||||
if ((this->name = strdup("node")) == NULL) {
|
||||
res = -errno;
|
||||
goto error_clean;
|
||||
}
|
||||
this->source.fd = -1;
|
||||
|
||||
if (properties == NULL)
|
||||
|
|
|
|||
|
|
@ -128,7 +128,10 @@ open_plugin(struct registry *registry,
|
|||
|
||||
pw_log_debug("loaded plugin:'%s'", filename);
|
||||
plugin->ref = 1;
|
||||
plugin->filename = strdup(filename);
|
||||
if ((plugin->filename = strdup(filename)) == NULL) {
|
||||
res = -errno;
|
||||
goto error_free;
|
||||
}
|
||||
plugin->hnd = hnd;
|
||||
plugin->enum_func = enum_func;
|
||||
plugin->log_topic_enum = dlsym(hnd, SPA_LOG_TOPIC_ENUM_NAME);
|
||||
|
|
@ -139,6 +142,8 @@ open_plugin(struct registry *registry,
|
|||
|
||||
return plugin;
|
||||
|
||||
error_free:
|
||||
free(plugin);
|
||||
error_dlclose:
|
||||
dlclose(hnd);
|
||||
error_out:
|
||||
|
|
@ -278,6 +283,11 @@ static struct spa_handle *load_spa_handle(const char *lib,
|
|||
handle->ref = 1;
|
||||
handle->plugin = plugin;
|
||||
handle->factory_name = strdup(factory_name);
|
||||
if (handle->factory_name == NULL) {
|
||||
pthread_mutex_unlock(&support_lock);
|
||||
res = -errno;
|
||||
goto error_free_handle;
|
||||
}
|
||||
spa_list_prepend(&sup->registry.handles, &handle->link);
|
||||
|
||||
return &handle->handle;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ struct pw_protocol *pw_protocol_new(struct pw_context *context,
|
|||
|
||||
protocol->context = context;
|
||||
protocol->name = strdup(name);
|
||||
if (protocol->name == NULL)
|
||||
goto error;
|
||||
|
||||
spa_list_init(&protocol->marshal_list);
|
||||
spa_list_init(&protocol->server_list);
|
||||
|
|
@ -52,6 +54,9 @@ struct pw_protocol *pw_protocol_new(struct pw_context *context,
|
|||
pw_log_debug("%p: Created protocol %s", protocol, name);
|
||||
|
||||
return protocol;
|
||||
error:
|
||||
free(protocol);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SPA_EXPORT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue