summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-11-28 20:35:52 +1100
committerMaxime Coste <mawww@kakoune.org>2019-11-28 20:35:52 +1100
commitb765fb4971db28bac608abc5cd856a9cb94fcfe1 (patch)
treefea89e261b9ba28794e4b441b1fc08ae79635f6e /src
parent805675b73165618d6b742d82fda9381d25eecc8f (diff)
parent7a384edeb08fe523bb2af8505c2fcd81c1bcf45c (diff)
Merge remote-tracking branch 'lenormf/fix-mmap-size-check'
Diffstat (limited to 'src')
-rw-r--r--src/file.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/file.cc b/src/file.cc
index c1f5bb26..fb282a14 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -217,13 +217,12 @@ MappedFile::MappedFile(StringView filename)
if (st.st_size == 0)
return;
+ else if (st.st_size > std::numeric_limits<int>::max())
+ throw runtime_error("file is too big");
data = (const char*)mmap(nullptr, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (data == MAP_FAILED)
throw file_access_error{filename, strerror(errno)};
-
- if (st.st_size > std::numeric_limits<int>::max())
- throw runtime_error("file is too big");
}
MappedFile::~MappedFile()