summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-05-28 12:40:17 +0900
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>2020-02-27 10:12:37 +0100
commit84e849bb006118bc24e8402754c6c5b624bc9efb (patch)
treea3576a83c6da2532298363c298880d39f8470f5d
parented560bc85cd2537dd083a8995b5d10f66f7a391f (diff)
downloadsystemd-84e849bb006118bc24e8402754c6c5b624bc9efb.tar.gz
journal: do not trigger assertion when journal_file_close() get NULL
We generally expect destructors to not complain if a NULL argument is passed. Closes #12400. (cherry picked from commit c377a6f3ad3d9bed4ce7e873e8e9ec6b1650c57d) (cherry picked from commit dc4c3a5aa35a5e88adcf210471d9460262c8c0d9) Resolves: #1807350
-rw-r--r--src/journal/journal-file.c3
-rw-r--r--src/journal/journald-server.c7
2 files changed, 4 insertions, 6 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index efc3ee052b..8249b11b23 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -335,7 +335,8 @@ bool journal_file_is_offlining(JournalFile *f) {
}
JournalFile* journal_file_close(JournalFile *f) {
- assert(f);
+ if (!f)
+ return NULL;
#if HAVE_GCRYPT
/* Write the final tag */
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index f2d2856e03..31a7b5ff03 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1906,11 +1906,8 @@ void server_done(Server *s) {
client_context_flush_all(s);
- if (s->system_journal)
- (void) journal_file_close(s->system_journal);
-
- if (s->runtime_journal)
- (void) journal_file_close(s->runtime_journal);
+ (void) journal_file_close(s->system_journal);
+ (void) journal_file_close(s->runtime_journal);
ordered_hashmap_free_with_destructor(s->user_journals, journal_file_close);