* mjit.c (init_header_filename): just FD instead of FILE to check
  file is accessible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-02-07 08:14:15 +00:00
Родитель 039db0d2fa
Коммит 2cb31e5327
1 изменённых файлов: 3 добавлений и 3 удалений

6
mjit.c
Просмотреть файл

@ -1107,7 +1107,7 @@ mjit_get_iseq_func(const struct rb_iseq_constant_body *body)
static void static void
init_header_filename(void) init_header_filename(void)
{ {
FILE *f; int fd;
/* Root path of the running ruby process. Equal to RbConfig::TOPDIR. */ /* Root path of the running ruby process. Equal to RbConfig::TOPDIR. */
VALUE basedir_val; VALUE basedir_val;
char *basedir; char *basedir;
@ -1134,12 +1134,12 @@ init_header_filename(void)
return; return;
p = append_str2(header_file, basedir, baselen); p = append_str2(header_file, basedir, baselen);
p = append_str2(p, header_name, sizeof(header_name)); p = append_str2(p, header_name, sizeof(header_name));
if ((f = fopen(header_file, "r")) == NULL) { if ((fd = rb_cloexec_open(header_file, O_RDONLY, 0)) < 0) {
xfree(header_file); xfree(header_file);
header_file = NULL; header_file = NULL;
return; return;
} }
fclose(f); (void)close(fd);
#ifdef _WIN32 #ifdef _WIN32
p = libruby_build = xmalloc(sizeof(libpathflag)-1 + baselen + 1); p = libruby_build = xmalloc(sizeof(libpathflag)-1 + baselen + 1);