mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pw-link: improve unlink
When we only have one argument, just check the link id and if that fails don't try to check the second argument because we would crash.
This commit is contained in:
parent
1b29531336
commit
9019edec31
1 changed files with 19 additions and 18 deletions
|
|
@ -339,25 +339,26 @@ static int do_unlink_ports(struct data *data)
|
|||
if (l->type != OBJECT_LINK)
|
||||
continue;
|
||||
|
||||
if (data->opt_input == NULL &&
|
||||
l->id == (uint32_t)atoi(data->opt_output))
|
||||
goto found;
|
||||
if (data->opt_input == NULL) {
|
||||
/* 1 arg, check link id */
|
||||
if (l->id != (uint32_t)atoi(data->opt_output))
|
||||
continue;
|
||||
} else {
|
||||
/* 2 args, check port names */
|
||||
if ((p = find_object(data, OBJECT_PORT, l->extra[0])) == NULL)
|
||||
continue;
|
||||
if ((n = find_object(data, OBJECT_NODE, p->extra[1])) == NULL)
|
||||
continue;
|
||||
if (!port_matches(data, n, p, data->opt_output))
|
||||
continue;
|
||||
|
||||
if ((p = find_object(data, OBJECT_PORT, l->extra[0])) == NULL)
|
||||
continue;
|
||||
if ((n = find_object(data, OBJECT_NODE, p->extra[1])) == NULL)
|
||||
continue;
|
||||
if (!port_matches(data, n, p, data->opt_output))
|
||||
continue;
|
||||
|
||||
if ((p = find_object(data, OBJECT_PORT, l->extra[1])) == NULL)
|
||||
continue;
|
||||
if ((n = find_object(data, OBJECT_NODE, p->extra[1])) == NULL)
|
||||
continue;
|
||||
if (!port_matches(data, n, p, data->opt_input))
|
||||
continue;
|
||||
|
||||
found:
|
||||
if ((p = find_object(data, OBJECT_PORT, l->extra[1])) == NULL)
|
||||
continue;
|
||||
if ((n = find_object(data, OBJECT_NODE, p->extra[1])) == NULL)
|
||||
continue;
|
||||
if (!port_matches(data, n, p, data->opt_input))
|
||||
continue;
|
||||
}
|
||||
link_id = l->id;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue