mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-12 05:34:05 -04:00
spa: support: loop: check enter_count before iterating
Calling "iterate()" on a loop that has not been entered by the calling thread is invalid. So try to diagnose misbehaving applications on a "best effort" basis by checking `impl::enter_count`. This is not a foolproof check, and can also technically cause data races while reading the variable. See #5148
This commit is contained in:
parent
dc1738ce57
commit
a661f14d2c
1 changed files with 4 additions and 0 deletions
|
|
@ -751,6 +751,8 @@ static int loop_iterate_cancel(void *object, int timeout)
|
|||
int i, nfds;
|
||||
uint32_t remove_count;
|
||||
|
||||
spa_return_val_if_fail(impl->enter_count > 0, -EPERM);
|
||||
|
||||
remove_count = impl->remove_count;
|
||||
spa_loop_control_hook_before(&impl->hooks_list);
|
||||
spa_assert_se(pthread_mutex_unlock(&impl->lock) == 0);
|
||||
|
|
@ -799,6 +801,8 @@ static int loop_iterate(void *object, int timeout)
|
|||
int i, nfds;
|
||||
uint32_t remove_count;
|
||||
|
||||
spa_return_val_if_fail(impl->enter_count > 0, -EPERM);
|
||||
|
||||
remove_count = impl->remove_count;
|
||||
spa_loop_control_hook_before(&impl->hooks_list);
|
||||
spa_assert_se(pthread_mutex_unlock(&impl->lock) == 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue