changeset 26020:31c1c2039678 v8.2.3544

patch 8.2.3544: Unix: may leak file descriptor using non-existing directory Commit: https://github.com/vim/vim/commit/051a40c8d91d4595c69a27375f739367d806a475 Author: itchyny <itchyny@hatena.ne.jp> Date: Wed Oct 20 10:00:05 2021 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 20 Oct 2021 11:15:04 +0200
parents 137f3bc03831
children ea28bf13ad1b
files src/os_unix.c src/version.c
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2681,7 +2681,6 @@ mch_FullName(
 		    verbose_leave();
 		}
 		l = fchdir(fd);
-		close(fd);
 	    }
 	    else
 #endif
@@ -2689,6 +2688,10 @@ mch_FullName(
 	    if (l != 0)
 		emsg(_(e_prev_dir));
 	}
+#ifdef HAVE_FCHDIR
+	if (fd >= 0)
+	    close(fd);
+#endif
 
 	l = STRLEN(buf);
 	if (l >= len - 1)
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3544,
+/**/
     3543,
 /**/
     3542,