|
|
ac3a84 |
From a9424191821c8c967edd7dd92a19d02ff5bbca87 Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
ac3a84 |
Date: Wed, 2 Nov 2022 07:06:46 +0900
|
|
|
ac3a84 |
Subject: [PATCH] core: fix memleak in GetUnitFileLinks method
|
|
|
ac3a84 |
|
|
|
ac3a84 |
(cherry picked from commit a12ba535fa677e642c7ba19e81062ed6e9365ceb)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related #2138081
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
src/core/dbus-manager.c | 16 +++++++++++-----
|
|
|
ac3a84 |
1 file changed, 11 insertions(+), 5 deletions(-)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
|
|
|
ac3a84 |
index 919aa58cde..88f098ec86 100644
|
|
|
ac3a84 |
--- a/src/core/dbus-manager.c
|
|
|
ac3a84 |
+++ b/src/core/dbus-manager.c
|
|
|
ac3a84 |
@@ -2647,21 +2647,27 @@ static int method_get_unit_file_links(sd_bus_message *message, void *userdata, s
|
|
|
ac3a84 |
(runtime ? UNIT_FILE_RUNTIME : 0);
|
|
|
ac3a84 |
|
|
|
ac3a84 |
r = unit_file_disable(LOOKUP_SCOPE_SYSTEM, flags, NULL, p, &changes, &n_changes);
|
|
|
ac3a84 |
- if (r < 0)
|
|
|
ac3a84 |
- return log_error_errno(r, "Failed to get file links for %s: %m", name);
|
|
|
ac3a84 |
+ if (r < 0) {
|
|
|
ac3a84 |
+ log_error_errno(r, "Failed to get file links for %s: %m", name);
|
|
|
ac3a84 |
+ goto finish;
|
|
|
ac3a84 |
+ }
|
|
|
ac3a84 |
|
|
|
ac3a84 |
for (i = 0; i < n_changes; i++)
|
|
|
ac3a84 |
if (changes[i].type == INSTALL_CHANGE_UNLINK) {
|
|
|
ac3a84 |
r = sd_bus_message_append(reply, "s", changes[i].path);
|
|
|
ac3a84 |
if (r < 0)
|
|
|
ac3a84 |
- return r;
|
|
|
ac3a84 |
+ goto finish;
|
|
|
ac3a84 |
}
|
|
|
ac3a84 |
|
|
|
ac3a84 |
r = sd_bus_message_close_container(reply);
|
|
|
ac3a84 |
if (r < 0)
|
|
|
ac3a84 |
- return r;
|
|
|
ac3a84 |
+ goto finish;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
- return sd_bus_send(NULL, reply, NULL);
|
|
|
ac3a84 |
+ r = sd_bus_send(NULL, reply, NULL);
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
+finish:
|
|
|
ac3a84 |
+ install_changes_free(changes, n_changes);
|
|
|
ac3a84 |
+ return r;
|
|
|
ac3a84 |
}
|
|
|
ac3a84 |
|
|
|
ac3a84 |
static int method_get_job_waiting(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|