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