pipewire: check init count before loading plugins

When pw_init() was not called and the init_count is 0, the plugin path
was not set and loading plugins will fail/segfault.

Avoid this and return en error early instead with a message that
pw_init() should be called first.

See !2784
This commit is contained in:
Wim Taymans 2026-04-13 09:30:53 +02:00
parent 11d28c661b
commit b12b7f785e

View file

@ -300,10 +300,18 @@ struct spa_handle *pw_load_spa_handle(const char *lib,
const struct spa_support support[])
{
struct spa_handle *handle;
struct support *sup = &global_support;
pthread_mutex_lock(&support_lock);
if (sup->init_count == 0)
goto error;
handle = load_spa_handle(lib, factory_name, info, n_support, support);
pthread_mutex_unlock(&support_lock);
return handle;
error:
pw_log_error("load lib: pw_init() was not called");
pthread_mutex_unlock(&support_lock);
errno = EBADFD;
return NULL;
}
static struct handle *find_handle(struct spa_handle *handle)