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()`.
This commit is contained in:
Barnabás Pőcze 2021-05-25 14:55:00 +02:00
parent 8e36353311
commit 1e9442e6b8

View file

@ -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); impl->pulse = pw_protocol_pulse_new(context, props, 0);
if (impl->pulse == NULL) { if (impl->pulse == NULL) {
res = -errno; res = -errno;
goto error; free(impl);
return res;
} }
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl); 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)); pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
return 0; return 0;
error:
impl_free(impl);
return res;
} }