daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
b9a53a
From dc4c3a5aa35a5e88adcf210471d9460262c8c0d9 Mon Sep 17 00:00:00 2001
bf443b
From: Yu Watanabe <watanabe.yu+github@gmail.com>
bf443b
Date: Tue, 28 May 2019 12:40:17 +0900
bf443b
Subject: [PATCH] journal: do not trigger assertion when journal_file_close()
bf443b
 get NULL
bf443b
bf443b
We generally expect destructors to not complain if a NULL argument is passed.
bf443b
bf443b
Closes #12400.
bf443b
bf443b
(cherry picked from commit c377a6f3ad3d9bed4ce7e873e8e9ec6b1650c57d)
b9a53a
Resolves: #1788085
bf443b
---
bf443b
 src/journal/journal-file.c    | 3 ++-
bf443b
 src/journal/journald-server.c | 7 ++-----
bf443b
 2 files changed, 4 insertions(+), 6 deletions(-)
bf443b
bf443b
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
bf443b
index efc3ee052b..8249b11b23 100644
bf443b
--- a/src/journal/journal-file.c
bf443b
+++ b/src/journal/journal-file.c
bf443b
@@ -335,7 +335,8 @@ bool journal_file_is_offlining(JournalFile *f) {
bf443b
 }
bf443b
 
bf443b
 JournalFile* journal_file_close(JournalFile *f) {
bf443b
-        assert(f);
bf443b
+        if (!f)
bf443b
+                return NULL;
bf443b
 
bf443b
 #if HAVE_GCRYPT
bf443b
         /* Write the final tag */
bf443b
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
b9a53a
index 6aecb67d6c..6250eab831 100644
bf443b
--- a/src/journal/journald-server.c
bf443b
+++ b/src/journal/journald-server.c
bf443b
@@ -1906,11 +1906,8 @@ void server_done(Server *s) {
bf443b
 
bf443b
         client_context_flush_all(s);
bf443b
 
bf443b
-        if (s->system_journal)
bf443b
-                (void) journal_file_close(s->system_journal);
bf443b
-
bf443b
-        if (s->runtime_journal)
bf443b
-                (void) journal_file_close(s->runtime_journal);
bf443b
+        (void) journal_file_close(s->system_journal);
bf443b
+        (void) journal_file_close(s->runtime_journal);
bf443b
 
bf443b
         ordered_hashmap_free_with_destructor(s->user_journals, journal_file_close);
bf443b