control: safely iterate the list, unlink modifies the list

This commit is contained in:
Wim Taymans 2018-03-08 11:03:50 +01:00
parent 1b2e73de0c
commit 6d569b132f

View file

@ -85,14 +85,14 @@ pw_control_new(struct pw_core *core,
void pw_control_destroy(struct pw_control *control)
{
struct impl *impl = SPA_CONTAINER_OF(control, struct impl, this);
struct pw_control *other;
struct pw_control *other, *tmp;
pw_log_debug("control %p: destroy", control);
spa_hook_list_call(&control->listener_list, struct pw_control_events, destroy);
if (control->direction == SPA_DIRECTION_OUTPUT) {
spa_list_for_each(other, &control->inputs, inputs_link)
spa_list_for_each_safe(other, tmp, &control->inputs, inputs_link)
pw_control_unlink(control, other);
}
else {