aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2022-06-25 08:21:05 +0200
committerNRK <nrk@disroot.org>2022-06-25 08:21:05 +0200
commit658a935c04ba6dd1bfb370ad0e209046dd90402f (patch)
treec06c4f6c2830611a9afb195525b0cc71961073f0 /main.c
parent9812d601c16fb243aac788abfeb9ea01a7870466 (diff)
downloadnsxiv-658a935c04ba6dd1bfb370ad0e209046dd90402f.tar.zst
fix: potentially printing wrong error message (#321)
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 <berke.kocaoglu@metu.edu.tr>
Diffstat (limited to 'main.c')
-rw-r--r--main.c2
1 files changed, 1 insertions, 1 deletions
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;
}