module: fix cleanup on error

This commit is contained in:
Wim Taymans 2019-07-09 16:53:31 +02:00
parent a6a7b3ab54
commit a3c0bb0e9a

View file

@ -230,6 +230,7 @@ pw_module_load(struct pw_core *core,
goto error_no_mem; goto error_no_mem;
impl->hnd = hnd; impl->hnd = hnd;
hnd = NULL;
this = &impl->this; this = &impl->this;
this->core = core; this->core = core;
@ -242,6 +243,7 @@ pw_module_load(struct pw_core *core,
this->info.name = name ? strdup(name) : NULL; this->info.name = name ? strdup(name) : NULL;
this->info.filename = filename; this->info.filename = filename;
filename = NULL;
this->info.args = args ? strdup(args) : NULL; this->info.args = args ? strdup(args) : NULL;
this->info.props = &this->properties->dict; this->info.props = &this->properties->dict;
@ -288,18 +290,20 @@ error_no_mem:
goto error_close; goto error_close;
error_no_global: error_no_global:
res = -errno; res = -errno;
pw_log_error("\"%s\": failed to create global: %m", filename); pw_log_error("\"%s\": failed to create global: %m", this->info.filename);
goto error_free_module; goto error_free_module;
error_init_failed: error_init_failed:
pw_log_error("\"%s\": failed to initialize: %s", filename, spa_strerror(res)); pw_log_error("\"%s\": failed to initialize: %s", this->info.filename, spa_strerror(res));
goto error_free_module; goto error_free_module;
error_free_module: error_free_module:
pw_module_destroy(this); pw_module_destroy(this);
error_close: error_close:
dlclose(hnd); if (hnd)
dlclose(hnd);
error_free_filename: error_free_filename:
free(filename); if (filename)
free(filename);
error_cleanup: error_cleanup:
if (properties) if (properties)
pw_properties_free(properties); pw_properties_free(properties);