hook: zero hooks before adding them

Clear the hook before adding it so that we are sure the removed
callback doesn't contain garbage and cause a crash on disconnect.

Mark the removed and priv fields as private. Make sure to add the
removed callback after adding the hook.

Fixes a crash in kwin
This commit is contained in:
Wim Taymans 2020-11-20 09:40:24 +01:00
parent 4d085816ef
commit fc2b0b20ad
3 changed files with 9 additions and 7 deletions

View file

@ -383,7 +383,6 @@ static void test_endpoint(void)
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, 1024);
spa_zero(d);
d.loop = pw_main_loop_new(NULL);
d.context = pw_context_new(pw_main_loop_get_loop(d.loop), NULL, 0);
spa_assert(d.context != NULL);