pulse-server: module-zeroconf-publish: avoid double-free

When a module's `load()` fails, its `unload()` will unconditionally
be called. Freeing resource in `load()` while not marking those
resources freed (e.g. setting the pointers to NULL) will result
in double-free when the module's `unload()` method is called.
This commit is contained in:
Barnabás Pőcze 2021-11-06 16:10:56 +01:00
parent 9a9fce66e0
commit 9769dee5e7

View file

@ -573,15 +573,12 @@ static int module_zeroconf_publish_load(struct client *client, struct module *mo
client_callback, data, &error); client_callback, data, &error);
if (!data->client) { if (!data->client) {
pw_log_error("avahi_client_new() failed: %s", avahi_strerror(error)); pw_log_error("avahi_client_new() failed: %s", avahi_strerror(error));
pw_avahi_poll_free(data->avahi_poll);
return -errno; return -errno;
} }
data->manager = pw_manager_new(data->core); data->manager = pw_manager_new(data->core);
if (client->manager == NULL) { if (client->manager == NULL) {
pw_log_error("Failed to create pipewire manager"); pw_log_error("Failed to create pipewire manager");
avahi_client_free(data->client);
pw_avahi_poll_free(data->avahi_poll);
return -errno; return -errno;
} }