aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2022-12-11 21:34:23 +0100
committerFelix Van der Jeugt <felix.vanderjeugt@posteo.net>2023-02-12 22:39:02 +0100
commit7e2d62de7b908b95933cdf20316324d9f82dac0d (patch)
tree763317faae988e81845759a660a7ef7f1e730515
parent1abf7eeea6b386c250249ab1ec6259bf0ccbb7c4 (diff)
downloadvis-7e2d62de7b908b95933cdf20316324d9f82dac0d.tar.gz
vis-7e2d62de7b908b95933cdf20316324d9f82dac0d.tar.xz
text-io: close "cwd" in all cases
-rw-r--r--text-io.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/text-io.c b/text-io.c
index a8d9cc0..509df35 100644
--- a/text-io.c
+++ b/text-io.c
@@ -242,9 +242,10 @@ static int mkstempat(int dirfd, char *template) {
fd = mkstemp(template);
err:
if (cwd != -1) {
- if (fchdir(cwd) != 0)
- return -1;
+ int ret = fchdir(cwd);
close(cwd);
+ if (ret != 0)
+ return -1;
}
return fd;
}