From 3bf2f9e26771eae5657243471227f975cc990797 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 6 May 2021 10:03:13 +0000 Subject: bugfix: rare fd leak in s6-log --- src/daemontools-extras/s6-log.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c index 798422d..29debb3 100644 --- a/src/daemontools-extras/s6-log.c +++ b/src/daemontools-extras/s6-log.c @@ -226,8 +226,14 @@ static inline int logdir_trim (logdir_t *ldp) dir_close(dir) ; return -1 ; } + if (!n) + { + dir_close(dir) ; + return 0 ; + } + rewinddir(dir) ; - if (n) + { uint64_t totalsize = 0 ; size_t dirlen = strlen(ldp->dir) ; -- cgit v1.2.3