Blob Blame History Raw
From a2e4c94df3d38cd2af73546ffd2623d9d1b20baa Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Mon, 3 Nov 2014 23:10:34 +0100
Subject: [PATCH] journald: fix memory leak on error path

(cherry picked from commit 26d8ff04914a5208d029e899682cd314b7714bf0)
---
 src/journal/journal-vacuum.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index 7699482a77..226af82da7 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -275,7 +275,11 @@ int journal_directory_vacuum(
 
                 patch_realtime(directory, p, &st, &realtime);
 
-                GREEDY_REALLOC(list, n_allocated, n_list + 1);
+                if (!GREEDY_REALLOC(list, n_allocated, n_list + 1)) {
+                        free(p);
+                        r = -ENOMEM;
+                        goto finish;
+                }
 
                 list[n_list].filename = p;
                 list[n_list].usage = 512UL * (uint64_t) st.st_blocks;