]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-journal: fix potential memory leak 31330/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Feb 2024 00:21:13 +0000 (09:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Feb 2024 00:50:18 +0000 (09:50 +0900)
Though, hopefully, the memory leak is hypothetical, as we always close
journal file with the timer by journal_file_offline_close().

src/libsystemd/sd-journal/journal-file.c
src/shared/journal-file-util.c

index 3f694cfabf11bf9bf802cab75e867b2c67c34b93..e96e4b6b9b801a8156cfe9538de1803708f49777 100644 (file)
@@ -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);
 
index f013836a370ff15027bb5a6f53e38f886a63d579..944c317c9a71cbfc4a27bea16813add626a34723 100644 (file)
@@ -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);