From: Yu Watanabe Date: Tue, 1 Nov 2022 22:06:46 +0000 (+0900) Subject: core: fix memleak in GetUnitFileLinks method X-Git-Tag: v253-rc1~609 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a12ba535fa677e642c7ba19e81062ed6e9365ceb;p=thirdparty%2Fsystemd.git core: fix memleak in GetUnitFileLinks method --- diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 919aa58cdee..88f098ec86c 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -2647,21 +2647,27 @@ static int method_get_unit_file_links(sd_bus_message *message, void *userdata, s (runtime ? UNIT_FILE_RUNTIME : 0); r = unit_file_disable(LOOKUP_SCOPE_SYSTEM, flags, NULL, p, &changes, &n_changes); - if (r < 0) - return log_error_errno(r, "Failed to get file links for %s: %m", name); + if (r < 0) { + log_error_errno(r, "Failed to get file links for %s: %m", name); + goto finish; + } for (i = 0; i < n_changes; i++) if (changes[i].type == INSTALL_CHANGE_UNLINK) { r = sd_bus_message_append(reply, "s", changes[i].path); if (r < 0) - return r; + goto finish; } r = sd_bus_message_close_container(reply); if (r < 0) - return r; + goto finish; - return sd_bus_send(NULL, reply, NULL); + r = sd_bus_send(NULL, reply, NULL); + +finish: + install_changes_free(changes, n_changes); + return r; } static int method_get_job_waiting(sd_bus_message *message, void *userdata, sd_bus_error *error) {