Blame SOURCES/0249-journal-rely-on-_cleanup_free_-to-free-a-temporary-s.patch

ddca0b
From 4d2145e3edd6ba6ac2e52a232fa5059ecdacaead Mon Sep 17 00:00:00 2001
a3e2b5
From: Evgeny Vereshchagin <evvers@ya.ru>
a3e2b5
Date: Mon, 24 Dec 2018 00:29:56 +0100
a3e2b5
Subject: [PATCH] journal: rely on _cleanup_free_ to free a temporary string
a3e2b5
 used in client_context_read_cgroup
a3e2b5
a3e2b5
Closes https://github.com/systemd/systemd/issues/11253.
a3e2b5
a3e2b5
(cherry picked from commit ef30f7cac18a810814ada7e6a68a31d48cc9fccd)
a3e2b5
ddca0b
Resolves: #1764560
a3e2b5
---
a3e2b5
 src/journal/journald-context.c | 7 ++-----
a3e2b5
 1 file changed, 2 insertions(+), 5 deletions(-)
a3e2b5
a3e2b5
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c
ddca0b
index c8e97e16de..3a768094d9 100644
a3e2b5
--- a/src/journal/journald-context.c
a3e2b5
+++ b/src/journal/journald-context.c
ddca0b
@@ -282,7 +282,7 @@ static int client_context_read_label(
a3e2b5
 }
a3e2b5
 
a3e2b5
 static int client_context_read_cgroup(Server *s, ClientContext *c, const char *unit_id) {
a3e2b5
-        char *t = NULL;
a3e2b5
+        _cleanup_free_ char *t = NULL;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
         assert(c);
ddca0b
@@ -290,7 +290,6 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u
a3e2b5
         /* Try to acquire the current cgroup path */
a3e2b5
         r = cg_pid_get_path_shifted(c->pid, s->cgroup_root, &t);
a3e2b5
         if (r < 0 || empty_or_root(t)) {
a3e2b5
-
a3e2b5
                 /* We use the unit ID passed in as fallback if we have nothing cached yet and cg_pid_get_path_shifted()
a3e2b5
                  * failed or process is running in a root cgroup. Zombie processes are automatically migrated to root cgroup
a3e2b5
                  * on cgroupsv1 and we want to be able to map log messages from them too. */
ddca0b
@@ -304,10 +303,8 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u
a3e2b5
         }
a3e2b5
 
a3e2b5
         /* Let's shortcut this if the cgroup path didn't change */
a3e2b5
-        if (streq_ptr(c->cgroup, t)) {
a3e2b5
-                free(t);
a3e2b5
+        if (streq_ptr(c->cgroup, t))
a3e2b5
                 return 0;
a3e2b5
-        }
a3e2b5
 
a3e2b5
         free_and_replace(c->cgroup, t);
a3e2b5