pw-link: avoid crash when proxy was already destroyed

When a link already exists, the link will fail and the proxy will be
destroyed and the pointer set to NULL. Avoid doing things with the NULL
pointer when cleaning up.
This commit is contained in:
Wim Taymans 2024-06-11 15:57:44 +02:00
parent c48c444566
commit cdfe95c091

View file

@ -842,8 +842,11 @@ static void data_clear(struct data *data)
struct target_link *tl; struct target_link *tl;
spa_list_consume(tl, &data->target_links, link) { spa_list_consume(tl, &data->target_links, link) {
spa_hook_remove(&tl->listener); if (tl->proxy != NULL) {
pw_proxy_destroy(tl->proxy); spa_hook_remove(&tl->listener);
spa_hook_remove(&tl->link_listener);
pw_proxy_destroy(tl->proxy);
}
spa_list_remove(&tl->link); spa_list_remove(&tl->link);
free(tl); free(tl);
} }