From fa859bb045b79d7f88979bac5345aed4fb4b3789 Mon Sep 17 00:00:00 2001 From: Stone Tickle Date: Fri, 11 Jun 2021 15:01:10 +0900 Subject: [PATCH] close error_msgout if opened --- cli/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/main.c b/cli/main.c index 2ac7ee3..837fa8b 100644 --- a/cli/main.c +++ b/cli/main.c @@ -802,6 +802,7 @@ main(int argc, char *argv[]) char *want_env_prefix = NULL; unsigned int want_client_flags = PKGCONF_PKG_PKGF_NONE; pkgconf_cross_personality_t *personality; + bool opened_error_msgout = false; want_flags = 0; @@ -1027,8 +1028,10 @@ main(int argc, char *argv[]) error_msgout = stderr; if ((want_flags & PKG_ERRORS_ON_STDOUT) == PKG_ERRORS_ON_STDOUT) error_msgout = stdout; - if ((want_flags & PKG_SILENCE_ERRORS) == PKG_SILENCE_ERRORS) + if ((want_flags & PKG_SILENCE_ERRORS) == PKG_SILENCE_ERRORS) { error_msgout = fopen(PATH_DEV_NULL, "w"); + opened_error_msgout = true; + } if ((want_flags & PKG_IGNORE_CONFLICTS) == PKG_IGNORE_CONFLICTS || getenv("PKG_CONFIG_IGNORE_CONFLICTS") != NULL) want_client_flags |= PKGCONF_PKG_PKGF_SKIP_CONFLICTS; @@ -1459,6 +1462,8 @@ out: if (logfile_out != NULL) fclose(logfile_out); + if (opened_error_msgout) + fclose(error_msgout); return ret; }