Do not use bare file descriptors

Reviewed By: nadavrot

Differential Revision: D3945330

fbshipit-source-id: f3a28e2632c7f17a0b6394f3dd3de183bc9e97af
This commit is contained in:
Michał Gregorczyk 2016-09-30 12:09:50 -07:00 коммит произвёл Facebook Github Bot
Родитель dbc853246d
Коммит 67f9d92478
1 изменённых файлов: 1 добавлений и 6 удалений

Просмотреть файл

@ -278,11 +278,7 @@ void JSCExecutor::loadApplicationScript(
int fd = open((bundlePath + UNPACKED_BYTECODE_SUFFIX).c_str(), O_RDONLY); int fd = open((bundlePath + UNPACKED_BYTECODE_SUFFIX).c_str(), O_RDONLY);
folly::checkUnixError(fd, "Couldn't open compiled bundle"); folly::checkUnixError(fd, "Couldn't open compiled bundle");
SCOPE_EXIT { close(fd); }; SCOPE_EXIT { close(fd); };
sourceCode = JSCreateCompiledSourceCode(fd, jsSourceURL);
auto length = lseek(fd, 0, SEEK_END);
folly::checkUnixError(length, "Couldn't seek to the end of compiled bundle");
sourceCode = JSCreateCompiledSourceCode(fd, length, jsSourceURL);
} else { } else {
auto jsScriptBigString = JSBigMmapString::fromOptimizedBundle(bundlePath); auto jsScriptBigString = JSBigMmapString::fromOptimizedBundle(bundlePath);
if (jsScriptBigString->encoding() != JSBigMmapString::Encoding::Ascii) { if (jsScriptBigString->encoding() != JSBigMmapString::Encoding::Ascii) {
@ -296,7 +292,6 @@ void JSCExecutor::loadApplicationScript(
sourceCode = JSCreateSourceCode( sourceCode = JSCreateSourceCode(
jsScriptBigString->fd(), jsScriptBigString->fd(),
jsScriptBigString->size(),
jsSourceURL, jsSourceURL,
jsScriptBigString->hash(), jsScriptBigString->hash(),
true); true);