Improve error message when registering empty bundles

Summary:
This change lets `registerBundle(bundleId, file)` throw an exception
when the file is empty, improving on the current behavior of an
eventual SIGABRT saying "MAP_FAILED: Invalid argument"

Reviewed By: ridiculousfish

Differential Revision: D16451938

fbshipit-source-id: b8b2d0bfed476319c379122fad59a5bf0a8c813b
This commit is contained in:
Will Holen
2019-07-23 17:43:34 -07:00
committed by Facebook Github Bot
parent 8b5ed7abdd
commit 691679a790
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -110,6 +110,9 @@ static off_t maybeRemap(char *data, size_t size, int fd) {
#endif // WITH_FBREMAP
const char *JSBigFileString::c_str() const {
if (m_size == 0) {
return "";
}
if (!m_data) {
m_data =
(const char *) mmap(0, m_size, PROT_READ, MAP_PRIVATE, m_fd, m_mapOff);