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 committed by Facebook Github Bot
parent dbc853246d
commit 67f9d92478
1 changed files with 1 additions and 6 deletions

View File

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