From f71ac477c8e4abf5fa3a49c87c8498b70be35be3 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Mon, 9 Sep 2024 12:27:54 +0800 Subject: [PATCH] Check mmap() result for MAP_FAILED --- httplib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index d56475a..ea014b6 100644 --- a/httplib.h +++ b/httplib.h @@ -2958,7 +2958,7 @@ inline bool mmap::open(const char *path) { addr_ = ::mmap(NULL, size_, PROT_READ, MAP_PRIVATE, fd_, 0); #endif - if (addr_ == nullptr) { + if (addr_ == nullptr || addr_ == MAP_FAILED) { close(); return false; }