mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
fail mmap::open when ::mmap returns MAP_FAILED
This commit is contained in:
1 parent
34b7c846d4
commit
f4fce42e77
2 files changed
+26
No files matched your search
@@ -5568,6 +5568,15 @@ inline bool mmap::open(const char *path) {
|
||||
is_open_empty_file = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// A failed mapping must not be left in `addr_`: `is_open()` only compares it
|
||||
// against nullptr, so the MAP_FAILED sentinel would pass and `data()` would
|
||||
// hand the caller (const char *)-1.
|
||||
if (addr_ == MAP_FAILED) {
|
||||
addr_ = nullptr;
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user