From 658a935c04ba6dd1bfb370ad0e209046dd90402f Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 25 Jun 2022 08:21:05 +0200 Subject: fix: potentially printing wrong error message (#321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit it's possible for the close() calls to override the errno resulting in incorrect error message being printed. call error() immediately to avoid such possibilities. also refactor a couple conditions to avoid doing multiple checks. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/321 Reviewed-by: Berke Kocaoğlu --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index f148250..1b50dd6 100644 --- a/main.c +++ b/main.c @@ -567,8 +567,8 @@ static bool run_key_handler(const char *key, unsigned int mask) if (pfd.writefd < 0) return false; if ((pfs = fdopen(pfd.writefd, "w")) == NULL) { - close(pfd.writefd); error(0, errno, "open pipe"); + close(pfd.writefd); return false; } -- cgit v1.2.3-54-g00ecf