From 1e9442e6b87f62076302ada2ec1b29fb6f85a2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 25 May 2021 14:55:00 +0200 Subject: [PATCH] pulse-server: fix memory issue Previously, when `pw_protocol_pulse_new()` returned NULL, the code would jump to the `error` label, which would call `impl_free()`. At this point, however, `impl->module_listener` is not initialized, which would lead to a SIGSEGV when `spa_hook_remove()` is called from `impl_free()`. --- src/modules/module-protocol-pulse.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/module-protocol-pulse.c b/src/modules/module-protocol-pulse.c index b19c6874c..189960c2f 100644 --- a/src/modules/module-protocol-pulse.c +++ b/src/modules/module-protocol-pulse.c @@ -99,7 +99,8 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) impl->pulse = pw_protocol_pulse_new(context, props, 0); if (impl->pulse == NULL) { res = -errno; - goto error; + free(impl); + return res; } pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl); @@ -107,7 +108,4 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props)); return 0; -error: - impl_free(impl); - return res; }