mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-17 07:00:03 -05:00
state: always update state variables
Or else we might leak the error string.
This commit is contained in:
parent
ef0e5ee09e
commit
f678f4371d
3 changed files with 21 additions and 20 deletions
|
|
@ -89,6 +89,10 @@ static void pw_impl_link_update_state(struct pw_impl_link *link, enum pw_link_st
|
||||||
{
|
{
|
||||||
enum pw_link_state old = link->info.state;
|
enum pw_link_state old = link->info.state;
|
||||||
|
|
||||||
|
link->info.state = state;
|
||||||
|
free((char*)link->info.error);
|
||||||
|
link->info.error = error;
|
||||||
|
|
||||||
if (state == old)
|
if (state == old)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -105,10 +109,6 @@ static void pw_impl_link_update_state(struct pw_impl_link *link, enum pw_link_st
|
||||||
pw_link_state_as_string(state));
|
pw_link_state_as_string(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
link->info.state = state;
|
|
||||||
free((char*)link->info.error);
|
|
||||||
link->info.error = error;
|
|
||||||
|
|
||||||
pw_impl_link_emit_state_changed(link, old, state, error);
|
pw_impl_link_emit_state_changed(link, old, state, error);
|
||||||
|
|
||||||
link->info.change_mask |= PW_LINK_CHANGE_MASK_STATE;
|
link->info.change_mask |= PW_LINK_CHANGE_MASK_STATE;
|
||||||
|
|
|
||||||
|
|
@ -285,9 +285,12 @@ do_node_add(struct spa_loop *loop,
|
||||||
|
|
||||||
static void node_update_state(struct pw_impl_node *node, enum pw_node_state state, char *error)
|
static void node_update_state(struct pw_impl_node *node, enum pw_node_state state, char *error)
|
||||||
{
|
{
|
||||||
enum pw_node_state old;
|
enum pw_node_state old = node->info.state;
|
||||||
|
|
||||||
|
free((char*)node->info.error);
|
||||||
|
node->info.error = error;
|
||||||
|
node->info.state = state;
|
||||||
|
|
||||||
old = node->info.state;
|
|
||||||
if (old == state)
|
if (old == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -302,10 +305,6 @@ static void node_update_state(struct pw_impl_node *node, enum pw_node_state stat
|
||||||
pw_node_state_as_string(old), pw_node_state_as_string(state));
|
pw_node_state_as_string(old), pw_node_state_as_string(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
free((char*)node->info.error);
|
|
||||||
node->info.error = error;
|
|
||||||
node->info.state = state;
|
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PW_NODE_STATE_RUNNING:
|
case PW_NODE_STATE_RUNNING:
|
||||||
pw_loop_invoke(node->data_loop, do_node_add, 1, NULL, 0, true, node);
|
pw_loop_invoke(node->data_loop, do_node_add, 1, NULL, 0, true, node);
|
||||||
|
|
|
||||||
|
|
@ -98,17 +98,19 @@ void pw_impl_port_update_state(struct pw_impl_port *port, enum pw_impl_port_stat
|
||||||
{
|
{
|
||||||
enum pw_impl_port_state old = port->state;
|
enum pw_impl_port_state old = port->state;
|
||||||
|
|
||||||
if (old != state) {
|
port->state = state;
|
||||||
|
free((void*)port->error);
|
||||||
|
port->error = error;
|
||||||
|
|
||||||
|
if (old == state)
|
||||||
|
return;
|
||||||
|
|
||||||
pw_log(state == PW_IMPL_PORT_STATE_ERROR ?
|
pw_log(state == PW_IMPL_PORT_STATE_ERROR ?
|
||||||
SPA_LOG_LEVEL_ERROR : SPA_LOG_LEVEL_DEBUG,
|
SPA_LOG_LEVEL_ERROR : SPA_LOG_LEVEL_DEBUG,
|
||||||
NAME" %p: state %s -> %s (%s)", port,
|
NAME" %p: state %s -> %s (%s)", port,
|
||||||
port_state_as_string(old), port_state_as_string(state), error);
|
port_state_as_string(old), port_state_as_string(state), error);
|
||||||
|
|
||||||
port->state = state;
|
|
||||||
free((void*)port->error);
|
|
||||||
port->error = error;
|
|
||||||
pw_impl_port_emit_state_changed(port, old, state, error);
|
pw_impl_port_emit_state_changed(port, old, state, error);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tee_process(void *object)
|
static int tee_process(void *object)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue