From 687cf3106304efecbd94fd0ae71af269921a737f Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 11 Jan 2026 15:47:57 +0300 Subject: [PATCH] Check for mmap call failure --- libs/jit/source/executable.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/jit/source/executable.cpp b/libs/jit/source/executable.cpp index 3e245d0..1366058 100644 --- a/libs/jit/source/executable.cpp +++ b/libs/jit/source/executable.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -18,8 +17,10 @@ namespace pslang::jit blob make_host_executable(std::vector const & code) { #if defined(__linux__) || defined(__APPLE__) -auto size = code.size(); + auto size = code.size(); auto ptr = (std::uint8_t *)mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + if (ptr == MAP_FAILED) + throw std::system_error(errno, std::generic_category()); std::copy(code.begin(), code.end(), ptr); if (mprotect(ptr, size, PROT_READ | PROT_EXEC) != 0) throw std::system_error(errno, std::generic_category());