From 1860d33fc9c9d05907db9bf02f1c81e0f517c09f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 7 Mar 2012 00:25:41 -0500 Subject: libsandbox: add missing close to logfile fd When we log a lot, we end up leaking fd's, so make sure to clean them. Signed-off-by: Mike Frysinger --- libsandbox/libsandbox.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c index 77a2415..e0b291a 100644 --- a/libsandbox/libsandbox.c +++ b/libsandbox/libsandbox.c @@ -468,6 +468,7 @@ static bool write_logfile(const char *logfile, const char *func, const char *pat struct stat log_stat; int stat_ret; int logfd; + bool ret = false; stat_ret = lstat(logfile, &log_stat); /* Do not care about failure */ @@ -523,10 +524,12 @@ static bool write_logfile(const char *logfile, const char *func, const char *pat } _SB_WRITE_STR("\n"); - return true; + ret = true; error: - return false; + sb_close(logfd); + + return ret; } static void init_context(sbcontext_t *context) -- cgit v1.2.3-65-gdbad