mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
link-factory: avoid using 0 for invalid id
Use SPA_ID_INVALID instead of 0 when we fail to parse the port id so that we don't accidentally match an internal port id. See #1724
This commit is contained in:
parent
0651e12ad8
commit
bd8ec29bb5
1 changed files with 7 additions and 5 deletions
|
|
@ -266,13 +266,14 @@ static struct pw_impl_port *find_port(struct pw_context *context,
|
||||||
struct pw_impl_node *node, enum spa_direction direction, const char *name)
|
struct pw_impl_node *node, enum spa_direction direction, const char *name)
|
||||||
{
|
{
|
||||||
struct find_port find = {
|
struct find_port find = {
|
||||||
.id = atoi(name),
|
.id = SPA_ID_INVALID,
|
||||||
.name = name,
|
.name = name,
|
||||||
.direction = direction,
|
.direction = direction,
|
||||||
.node = node
|
.node = node
|
||||||
};
|
};
|
||||||
|
spa_atou32(name, &find.id, 0);
|
||||||
|
|
||||||
if (find.id != 0) {
|
if (find.id != SPA_ID_INVALID) {
|
||||||
struct pw_global *global = pw_context_find_global(context, find.id);
|
struct pw_global *global = pw_context_find_global(context, find.id);
|
||||||
/* find port by global id */
|
/* find port by global id */
|
||||||
if (global != NULL && pw_global_is_type(global, PW_TYPE_INTERFACE_Port))
|
if (global != NULL && pw_global_is_type(global, PW_TYPE_INTERFACE_Port))
|
||||||
|
|
@ -280,7 +281,7 @@ static struct pw_impl_port *find_port(struct pw_context *context,
|
||||||
}
|
}
|
||||||
if (node != NULL) {
|
if (node != NULL) {
|
||||||
/* find port by local id */
|
/* find port by local id */
|
||||||
if (find.id != 0) {
|
if (find.id != SPA_ID_INVALID) {
|
||||||
find.port = pw_impl_node_find_port(node, find.direction, find.id);
|
find.port = pw_impl_node_find_port(node, find.direction, find.id);
|
||||||
if (find.port != NULL)
|
if (find.port != NULL)
|
||||||
return find.port;
|
return find.port;
|
||||||
|
|
@ -337,11 +338,12 @@ found:
|
||||||
static struct pw_impl_node *find_node(struct pw_context *context, const char *name)
|
static struct pw_impl_node *find_node(struct pw_context *context, const char *name)
|
||||||
{
|
{
|
||||||
struct find_node find = {
|
struct find_node find = {
|
||||||
.id = atoi(name),
|
.id = SPA_ID_INVALID,
|
||||||
.name = name,
|
.name = name,
|
||||||
};
|
};
|
||||||
|
spa_atou32(name, &find.id, 0);
|
||||||
|
|
||||||
if (find.id != 0) {
|
if (find.id != SPA_ID_INVALID) {
|
||||||
struct pw_global *global = pw_context_find_global(context, find.id);
|
struct pw_global *global = pw_context_find_global(context, find.id);
|
||||||
if (global != NULL && pw_global_is_type(global, PW_TYPE_INTERFACE_Node))
|
if (global != NULL && pw_global_is_type(global, PW_TYPE_INTERFACE_Node))
|
||||||
return pw_global_get_object(global);
|
return pw_global_get_object(global);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue