* ruby.c (load_file_internal): fix potential fd leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-10-16 23:24:37 +00:00
Родитель 7a8a49d98a
Коммит 34b877e491
1 изменённых файлов: 5 добавлений и 5 удалений

10
ruby.c
Просмотреть файл

@ -1760,11 +1760,11 @@ load_file_internal(VALUE arg)
#if !defined DOSISH && !defined __CYGWIN__
{
struct stat st;
if (fstat(fd, &st) != 0)
rb_load_fail(fname_v, strerror(errno));
if (S_ISDIR(st.st_mode)) {
errno = EISDIR;
rb_load_fail(fname_v, strerror(EISDIR));
int e;
if ((fstat(fd, &st) != 0) && (e = errno, 1) ||
(S_ISDIR(st.st_mode) && (e = EISDIR, 1))) {
(void)close(fd);
rb_load_fail(fname_v, strerror(e));
}
}
#endif