]> granicus.if.org Git - vim/commitdiff
patch 8.2.3544: Unix: may leak file descriptor using non-existing directory v8.2.3544
authoritchyny <itchyny@hatena.ne.jp>
Wed, 20 Oct 2021 09:00:05 +0000 (10:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 20 Oct 2021 09:00:05 +0000 (10:00 +0100)
Problem:    Unix: may leak file descriptor when using a non-existing
            directory.
Solution:   Always close the file. (closes #9023)

src/os_unix.c
src/version.c

index 9dde754f3ae40036aa272750105a916271956ea7..0b2b5725eb78268d3787f33be1eab2cb2592da42 100644 (file)
@@ -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)
index c3f1fd6ab06ee589baeb6dbfb5f84a7e03889b84..227db829a9f031bec7a4442cebb97e66a0c5d97d 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3544,
 /**/
     3543,
 /**/