From fb1078b2e83445756e77e636a5f222f9d2c95c5a Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Wed, 26 Apr 2023 20:54:08 +0900
Subject: [PATCH] sd-journal: make journal_file_copy_entry() return earlier

(cherry picked from commit 85e38da2ec2d9d3a56659105fe4d47c84462d5f9)
(cherry picked from commit df9d1d9bb20846d081cfddfc271b40fdd0550b92)
(cherry picked from commit 141b891de7d420d5fce706e376403007dbf77712)

Conflict:code context adaptation
Reference:https://github.com/systemd/systemd-stable/commit/fb1078b2e83445756e77e636a5f222f9d2c95c5a
---
 src/libsystemd/sd-journal/journal-file.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 6561b12aca..a415dafedd 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -3757,6 +3757,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
         boot_id = o->entry.boot_id;
 
         n = journal_file_entry_n_items(o);
+        if (n == 0)
+                return 0;
         /* alloca() can't take 0, hence let's allocate at least one */
         items = newa(EntryItem, MAX(1u, n));
 
-- 
2.33.0

