aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}