mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
hook: don't remove from unitialized list
A lot of code calls spa_hook_remove() from error paths where the hook and therefore the list may not have been initialized. This leads to null-derefences.
This commit is contained in:
parent
b23b0e6125
commit
2394413ec3
|
@ -382,6 +382,7 @@ static inline void spa_hook_list_prepend(struct spa_hook_list *list,
|
||||||
/** Remove a hook */
|
/** Remove a hook */
|
||||||
static inline void spa_hook_remove(struct spa_hook *hook)
|
static inline void spa_hook_remove(struct spa_hook *hook)
|
||||||
{
|
{
|
||||||
|
if (spa_list_is_initialized(&hook->link))
|
||||||
spa_list_remove(&hook->link);
|
spa_list_remove(&hook->link);
|
||||||
if (hook->removed)
|
if (hook->removed)
|
||||||
hook->removed(hook);
|
hook->removed(hook);
|
||||||
|
|
|
@ -419,6 +419,12 @@ PWTEST(utils_hook)
|
||||||
}
|
}
|
||||||
pwtest_int_eq(count, 4);
|
pwtest_int_eq(count, 4);
|
||||||
pwtest_int_eq(hook_free_count, 4);
|
pwtest_int_eq(hook_free_count, 4);
|
||||||
|
|
||||||
|
/* remove a zeroed hook */
|
||||||
|
struct spa_hook hook;
|
||||||
|
spa_zero(hook);
|
||||||
|
spa_hook_remove(&hook);
|
||||||
|
|
||||||
return PWTEST_PASS;
|
return PWTEST_PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue