daandemeyer / rpms / systemd

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