From f0c03de85afa93d1df2bb533a46748e7f4264af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jan 2017 22:21:16 -0500 Subject: [PATCH 1/3] core/dbus: fix two strv memleaks job_dbus_path and unit_dbus_path both allocate new strings, so we should use strv_free. --- src/core/dbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/dbus.c b/src/core/dbus.c index 1f9bf2085f7..a3f701c0645 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -477,7 +477,7 @@ static int bus_kill_context_find(sd_bus *bus, const char *path, const char *inte } static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) { - _cleanup_free_ char **l = NULL; + _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; unsigned k = 0; Iterator i; @@ -504,7 +504,7 @@ static int bus_job_enumerate(sd_bus *bus, const char *path, void *userdata, char } static int bus_unit_enumerate(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) { - _cleanup_free_ char **l = NULL; + _cleanup_strv_free_ char **l = NULL; Manager *m = userdata; unsigned k = 0; Iterator i; From 06ec51d8ef30dce3c7f864633ba3a9888d18fed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jan 2017 22:24:07 -0500 Subject: [PATCH 2/3] core/execute: fix strv memleak compile_read_write_paths() returns a normal strv from strv_copy(), and setup_namespace() uses it read-only, so we should use strv_free to deallocate. --- src/core/execute.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/execute.c b/src/core/execute.c index 06a291fd394..d0faba5a858 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1896,8 +1896,8 @@ static int compile_read_write_paths( _cleanup_strv_free_ char **l = NULL; char **rt; - /* Compile the list of writable paths. This is the combination of the explicitly configured paths, plus all - * runtime directories. */ + /* Compile the list of writable paths. This is the combination of + * the explicitly configured paths, plus all runtime directories. */ if (strv_isempty(context->read_write_paths) && strv_isempty(context->runtime_directory)) { @@ -1930,7 +1930,7 @@ static int apply_mount_namespace(Unit *u, const ExecContext *context, const ExecParameters *params, ExecRuntime *runtime) { int r; - _cleanup_free_ char **rw = NULL; + _cleanup_strv_free_ char **rw = NULL; char *tmp = NULL, *var = NULL; const char *root_dir = NULL; NameSpaceInfo ns_info = { From c6d92582205065e4924b9f0cb1428f4a5f210fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jan 2017 22:27:21 -0500 Subject: [PATCH 3/3] resolve: fix strv memleak sd_bus_message_read_strv() returns a normal strv... --- src/resolve/resolved-link-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c index 364812250fa..59cd6cf1cbb 100644 --- a/src/resolve/resolved-link-bus.c +++ b/src/resolve/resolved-link-bus.c @@ -462,7 +462,7 @@ int bus_link_method_set_dnssec(sd_bus_message *message, void *userdata, sd_bus_e int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, void *userdata, sd_bus_error *error) { _cleanup_set_free_free_ Set *ns = NULL; - _cleanup_free_ char **ntas = NULL; + _cleanup_strv_free_ char **ntas = NULL; Link *l = userdata; int r; char **i;