patch 8.2.3544: Unix: may leak file descriptor using non-existing directory
Problem: Unix: may leak file descriptor when using a non-existing
directory.
Solution: Always close the file. (closes #9023)
diff --git a/src/os_unix.c b/src/os_unix.c
index 9dde754..0b2b572 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2681,7 +2681,6 @@
verbose_leave();
}
l = fchdir(fd);
- close(fd);
}
else
#endif
@@ -2689,6 +2688,10 @@
if (l != 0)
emsg(_(e_prev_dir));
}
+#ifdef HAVE_FCHDIR
+ if (fd >= 0)
+ close(fd);
+#endif
l = STRLEN(buf);
if (l >= len - 1)