mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
module: Assign the index before calling init()
Any code that runs inside the init() callback sees an invalid module index. Sometimes init() does things that cause hooks to be fired. This means that any code that uses hooks may see an invalid module index. Fix this by assigning the module index before init() is called. There are no known issues in the upstream code base where an invalid module index would be used, but an out-of-tree module (module-murphy-ivi) had a problem with this. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=63923
This commit is contained in:
parent
6cc974844e
commit
aacac20e76
1 changed files with 6 additions and 3 deletions
|
|
@ -113,14 +113,14 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
|||
m->core = c;
|
||||
m->unload_requested = FALSE;
|
||||
|
||||
pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
|
||||
pa_assert(m->index != PA_IDXSET_INVALID);
|
||||
|
||||
if (m->init(m) < 0) {
|
||||
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"): initialization failed.", name, argument ? argument : "");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
|
||||
pa_assert(m->index != PA_IDXSET_INVALID);
|
||||
|
||||
pa_log_info("Loaded \"%s\" (index: #%u; argument: \"%s\").", m->name, m->index, m->argument ? m->argument : "");
|
||||
|
||||
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
|
||||
|
|
@ -144,6 +144,9 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
|||
fail:
|
||||
|
||||
if (m) {
|
||||
if (m->index != PA_IDXSET_INVALID)
|
||||
pa_idxset_remove_by_index(c->modules, m->index);
|
||||
|
||||
if (m->proplist)
|
||||
pa_proplist_free(m->proplist);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue