0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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)
This commit is contained in:
itchyny 2021-10-20 10:00:05 +01:00 committed by Bram Moolenaar
parent 8b0e62c93b
commit 051a40c8d9
2 changed files with 6 additions and 1 deletions

View File

@ -2681,7 +2681,6 @@ mch_FullName(
verbose_leave(); verbose_leave();
} }
l = fchdir(fd); l = fchdir(fd);
close(fd);
} }
else else
#endif #endif
@ -2689,6 +2688,10 @@ mch_FullName(
if (l != 0) if (l != 0)
emsg(_(e_prev_dir)); emsg(_(e_prev_dir));
} }
#ifdef HAVE_FCHDIR
if (fd >= 0)
close(fd);
#endif
l = STRLEN(buf); l = STRLEN(buf);
if (l >= len - 1) if (l >= len - 1)

View File

@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3544,
/**/ /**/
3543, 3543,
/**/ /**/