summaryrefslogtreecommitdiff
path: root/src/journal/journal-vacuum.c
diff options
context:
space:
mode:
authorGeorge McCollister <george.mccollister@gmail.com>2013-09-04 07:12:44 -0500
committerHarald Hoyer <harald@redhat.com>2013-09-06 07:11:25 +0200
commit489798614cefed16db5f086c3fa9a301f0276fd8 (patch)
tree55f3cc0bcb1f8406a3b3f32eddda0a4293c26c4f /src/journal/journal-vacuum.c
parent629bfc5a7fbbe4861b5cde857140f623d5de5ec5 (diff)
journald: fix fd leak in journal_file_empty
Before my previous patch, journal_file_empty wasn't be called with the correct filename. Now that it's being called with the correct filename it leaks file descriptors. This patch closes the file descriptors before returning. Signed-off-by: George McCollister <george.mccollister@gmail.com> [Edit harald@redhat.com: make use of _cleanup_close_ instead]
Diffstat (limited to 'src/journal/journal-vacuum.c')
-rw-r--r--src/journal/journal-vacuum.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index ace772273b..178c8030db 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -129,8 +129,9 @@ static void patch_realtime(
}
static int journal_file_empty(int dir_fd, const char *name) {
- int fd, r;
+ int r;
le64_t n_entries;
+ _cleanup_close_ int fd;
fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
if (fd < 0)