diff --git a/ReactCommon/cxxreact/JSBigString.h b/ReactCommon/cxxreact/JSBigString.h index 33a92d117..0a16e551d 100644 --- a/ReactCommon/cxxreact/JSBigString.h +++ b/ReactCommon/cxxreact/JSBigString.h @@ -112,20 +112,25 @@ public: : m_fd {-1} , m_data {nullptr} { - folly::checkUnixError( - m_fd = dup(fd), - "Could not duplicate file descriptor"); + folly::checkUnixError(m_fd = dup(fd), + "Could not duplicate file descriptor"); // Offsets given to mmap must be page aligend. We abstract away that // restriction by sending a page aligned offset to mmap, and keeping track // of the offset within the page that we must alter the mmap pointer by to // get the final desired offset. - auto ps = getpagesize(); - auto d = lldiv(offset, ps); + if (offset != 0) { + const static auto ps = getpagesize(); + auto d = lldiv(offset, ps); - m_mapOff = d.quot; - m_pageOff = d.rem; - m_size = size + m_pageOff; + m_mapOff = d.quot; + m_pageOff = d.rem; + m_size = size + m_pageOff; + } else { + m_mapOff = 0; + m_pageOff = 0; + m_size = size; + } } ~JSBigFileString() {