Merge branch 'mmap-map-failed-guard' of github.com:metsw24-max/cpp-httplib into metsw24-max-mmap-map-failed-guard

This commit is contained in:
yhirose committed 2026-08-01 22:16:28 -04:00
commit 2e37c51921
2 files changed
+26

No files matched your search

+9
View File
@@ -5576,6 +5576,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;