ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
2f7d91
From d8c33d7a4e0d9b4375159776913f5c3fd2905c21 Mon Sep 17 00:00:00 2001
2f7d91
From: Jan Synacek <jsynacek@redhat.com>
2f7d91
Date: Tue, 7 Jan 2020 11:22:26 +0100
2f7d91
Subject: [PATCH] journal: do not trigger assertion when journal_file_close()
2f7d91
 get NULL
2f7d91
2f7d91
We generally expect destructors to not complain if a NULL argument is passed.
2f7d91
2f7d91
Closes #12400.
2f7d91
2f7d91
(cherry picked from commit c377a6f3ad3d9bed4ce7e873e8e9ec6b1650c57d)
2f7d91
(cherry picked from commit 248925c68092bab7ce0231449176db153f55d818)
2f7d91
Resolves: #1807798
2f7d91
---
2f7d91
 src/journal/journal-file.c    | 3 ++-
2f7d91
 src/journal/journald-server.c | 7 ++-----
2f7d91
 2 files changed, 4 insertions(+), 6 deletions(-)
2f7d91
2f7d91
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
2f7d91
index 586f620e21..cf8dad3fcd 100644
2f7d91
--- a/src/journal/journal-file.c
2f7d91
+++ b/src/journal/journal-file.c
2f7d91
@@ -129,7 +129,8 @@ int journal_file_set_offline(JournalFile *f) {
2f7d91
 }
2f7d91
 
2f7d91
 void journal_file_close(JournalFile *f) {
2f7d91
-        assert(f);
2f7d91
+        if (!f)
2f7d91
+                return;
2f7d91
 
2f7d91
 #ifdef HAVE_GCRYPT
2f7d91
         /* Write the final tag */
2f7d91
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
2f7d91
index aaabb2f7ab..ffe2daa7be 100644
2f7d91
--- a/src/journal/journald-server.c
2f7d91
+++ b/src/journal/journald-server.c
2f7d91
@@ -1933,11 +1933,8 @@ void server_done(Server *s) {
2f7d91
         while (s->stdout_streams)
2f7d91
                 stdout_stream_free(s->stdout_streams);
2f7d91
 
2f7d91
-        if (s->system_journal)
2f7d91
-                journal_file_close(s->system_journal);
2f7d91
-
2f7d91
-        if (s->runtime_journal)
2f7d91
-                journal_file_close(s->runtime_journal);
2f7d91
+        (void) journal_file_close(s->system_journal);
2f7d91
+        (void) journal_file_close(s->runtime_journal);
2f7d91
 
2f7d91
         while ((f = ordered_hashmap_steal_first(s->user_journals)))
2f7d91
                 journal_file_close(f);