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