module: handle type register errors

Registering an export type can give an error when the type is already
registered. Handle those errors and refuse to load the module.

See #2281
This commit is contained in:
Wim Taymans 2022-04-11 21:15:13 +02:00
parent 37fa911a72
commit b97327e1f6
7 changed files with 50 additions and 13 deletions

View file

@ -531,6 +531,7 @@ int endpoint_stream_factory_init(struct pw_impl_module *module)
struct pw_context *context = pw_impl_module_get_context(module);
struct pw_impl_factory *factory;
struct factory_data *data;
int res;
factory = pw_context_create_factory(context,
"endpoint-stream",
@ -549,9 +550,13 @@ int endpoint_stream_factory_init(struct pw_impl_module *module)
data->export.type = PW_TYPE_INTERFACE_EndpointStream;
data->export.func = pw_core_endpoint_stream_export;
pw_context_register_export_type(context, &data->export);
if ((res = pw_context_register_export_type(context, &data->export)) < 0)
goto error;
pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
return 0;
error:
pw_impl_factory_destroy(data->this);
return res;
}