From: Yu Watanabe Date: Wed, 14 Feb 2024 00:21:13 +0000 (+0900) Subject: sd-journal: fix potential memory leak X-Git-Tag: v256-rc1~853^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F31330%2Fhead;p=thirdparty%2Fsystemd.git sd-journal: fix potential memory leak Though, hopefully, the memory leak is hypothetical, as we always close journal file with the timer by journal_file_offline_close(). --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index 3f694cfabf1..e96e4b6b9b8 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -281,6 +281,8 @@ JournalFile* journal_file_close(JournalFile *f) { assert(f->newest_boot_id_prioq_idx == PRIOQ_IDX_NULL); + sd_event_source_disable_unref(f->post_change_timer); + if (f->cache_fd) mmap_cache_fd_free(f->cache_fd); diff --git a/src/shared/journal-file-util.c b/src/shared/journal-file-util.c index f013836a370..944c317c9a7 100644 --- a/src/shared/journal-file-util.c +++ b/src/shared/journal-file-util.c @@ -399,7 +399,7 @@ JournalFile* journal_file_offline_close(JournalFile *f) { if (sd_event_source_get_enabled(f->post_change_timer, NULL) > 0) journal_file_post_change(f); - sd_event_source_disable_unref(f->post_change_timer); + f->post_change_timer = sd_event_source_disable_unref(f->post_change_timer); journal_file_set_offline(f, true);