From 0e823d8a0f21a8fbdbceee656ad43b865b815173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 26 Jun 2023 15:19:43 +0200 Subject: [PATCH] pipewire: core: static assert member order requirement The pw_proxy member of pw_core must be the first because the pw_core object is freed via pw_proxy_destroy() -> pw_proxy_unref(). --- src/pipewire/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pipewire/core.c b/src/pipewire/core.c index 48931a017..2fe0eb79e 100644 --- a/src/pipewire/core.c +++ b/src/pipewire/core.c @@ -476,6 +476,12 @@ struct pw_mempool * pw_core_get_mempool(struct pw_core *core) SPA_EXPORT int pw_core_disconnect(struct pw_core *core) { + /* + * the `proxy` member must be the first because the whole pw_core object is + * freed via the free() call in pw_proxy_destroy() -> pw_proxy_unref() + */ + SPA_STATIC_ASSERT(offsetof(struct pw_core, proxy) == 0, "`proxy` member must be first"); + pw_log_debug("%p: disconnect", core); if (!core->removed) pw_proxy_remove(&core->proxy);