mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Fix some leaks in error cases
This commit is contained in:
parent
8669fd03a6
commit
c2028a1695
9 changed files with 43 additions and 22 deletions
|
|
@ -442,10 +442,6 @@ static struct endpoint *create_endpoint(struct node *node, struct endpoint *moni
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strstr(media_class, "Source") != NULL) {
|
||||
direction = PW_DIRECTION_OUTPUT;
|
||||
} else if (strstr(media_class, "Sink") != NULL) {
|
||||
|
|
@ -455,6 +451,10 @@ static struct endpoint *create_endpoint(struct node *node, struct endpoint *moni
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
if (monitor != NULL) {
|
||||
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
||||
direction = PW_DIRECTION_OUTPUT;
|
||||
|
|
|
|||
|
|
@ -437,10 +437,6 @@ static struct endpoint *create_endpoint(struct node *node, struct endpoint *moni
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strstr(media_class, "Source") != NULL) {
|
||||
direction = PW_DIRECTION_OUTPUT;
|
||||
} else if (strstr(media_class, "Sink") != NULL) {
|
||||
|
|
@ -450,6 +446,10 @@ static struct endpoint *create_endpoint(struct node *node, struct endpoint *moni
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
if (monitor != NULL) {
|
||||
pw_properties_set(props, PW_KEY_MEDIA_CLASS, "Audio/Source");
|
||||
direction = PW_DIRECTION_OUTPUT;
|
||||
|
|
|
|||
|
|
@ -392,10 +392,6 @@ static struct endpoint *create_endpoint(struct node *node)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
if (strstr(media_class, "Source") != NULL) {
|
||||
direction = PW_DIRECTION_OUTPUT;
|
||||
} else if (strstr(media_class, "Sink") != NULL) {
|
||||
|
|
@ -405,6 +401,10 @@ static struct endpoint *create_endpoint(struct node *node)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
return NULL;
|
||||
|
||||
pw_properties_set(props, PW_KEY_MEDIA_CLASS, media_class);
|
||||
|
||||
if ((str = pw_properties_get(pr, PW_KEY_PRIORITY_SESSION)) != NULL)
|
||||
|
|
|
|||
|
|
@ -210,8 +210,10 @@ pw_client_node0_transport_new(struct pw_context *context,
|
|||
PW_MEMBLOCK_FLAG_MAP |
|
||||
PW_MEMBLOCK_FLAG_SEAL,
|
||||
SPA_DATA_MemFd, area_get_size(&area));
|
||||
if (impl->mem == NULL)
|
||||
if (impl->mem == NULL) {
|
||||
free(impl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(impl->mem->map->ptr, &area, sizeof(struct pw_client_node0_area));
|
||||
transport_setup_area(impl->mem->map->ptr, trans);
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
props,
|
||||
sizeof(struct device_data));
|
||||
if (device == NULL) {
|
||||
props = NULL;
|
||||
res = -errno;
|
||||
goto error_exit_cleanup;
|
||||
}
|
||||
|
|
@ -119,5 +120,7 @@ error_arguments:
|
|||
error_exit_cleanup:
|
||||
if (argv)
|
||||
pw_free_strv(argv);
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1031,11 +1031,14 @@ pw_filter_new_simple(struct pw_loop *loop,
|
|||
return NULL;
|
||||
|
||||
context = pw_context_new(loop, NULL, 0);
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
if (context == NULL) {
|
||||
res = -errno;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
impl = filter_new(context, name, props, props);
|
||||
if (impl == NULL) {
|
||||
props = NULL;
|
||||
res = -errno;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
|
@ -1048,7 +1051,10 @@ pw_filter_new_simple(struct pw_loop *loop,
|
|||
return this;
|
||||
|
||||
error_cleanup:
|
||||
pw_context_destroy(context);
|
||||
if (context)
|
||||
pw_context_destroy(context);
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
errno = -res;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static char *find_module(const char *path, const char *name)
|
|||
|
||||
newpath = spa_aprintf("%s/%s", path, entry->d_name);
|
||||
if (newpath == NULL)
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
if (stat(newpath, &s) == 0 && S_ISDIR(s.st_mode)) {
|
||||
filename = find_module(newpath, name);
|
||||
|
|
|
|||
|
|
@ -43,8 +43,11 @@ static int add_func(struct pw_properties *this, char *key, char *value)
|
|||
struct properties *impl = SPA_CONTAINER_OF(this, struct properties, this);
|
||||
|
||||
item = pw_array_add(&impl->items, sizeof(struct spa_dict_item));
|
||||
if (item == NULL)
|
||||
if (item == NULL) {
|
||||
free(key);
|
||||
free(value);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
item->key = key;
|
||||
item->value = value;
|
||||
|
|
|
|||
|
|
@ -1182,12 +1182,15 @@ pw_stream_new_simple(struct pw_loop *loop,
|
|||
return NULL;
|
||||
|
||||
context = pw_context_new(loop, NULL, 0);
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
if (context == NULL) {
|
||||
res = -errno;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
impl = stream_new(context, name, props, NULL);
|
||||
if (impl == NULL) {
|
||||
res = -errno;
|
||||
props = NULL;
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
|
|
@ -1198,7 +1201,10 @@ pw_stream_new_simple(struct pw_loop *loop,
|
|||
return this;
|
||||
|
||||
error_cleanup:
|
||||
pw_context_destroy(context);
|
||||
if (context)
|
||||
pw_context_destroy(context);
|
||||
if (props)
|
||||
pw_properties_free(props);
|
||||
errno = -res;
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1390,7 +1396,7 @@ pw_stream_connect(struct pw_stream *stream,
|
|||
{
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
struct pw_impl_factory *factory;
|
||||
struct pw_properties *props;
|
||||
struct pw_properties *props = NULL;
|
||||
struct pw_impl_node *follower;
|
||||
const char *str;
|
||||
uint32_t i;
|
||||
|
|
@ -1520,6 +1526,7 @@ pw_stream_connect(struct pw_stream *stream,
|
|||
}
|
||||
} else {
|
||||
impl->node = follower;
|
||||
pw_properties_free(props);
|
||||
}
|
||||
if (!SPA_FLAG_IS_SET(impl->flags, PW_STREAM_FLAG_INACTIVE))
|
||||
pw_impl_node_set_active(impl->node, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue