From 6fc643f4833306cf1b53f2146a95de28182e0c46 Mon Sep 17 00:00:00 2001 From: Elad <18193363+elad335@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:42:25 +0200 Subject: [PATCH] JITASM.cpp: add assert for code building --- Utilities/JITASM.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Utilities/JITASM.cpp b/Utilities/JITASM.cpp index 642eb631bc..493380c600 100644 --- a/Utilities/JITASM.cpp +++ b/Utilities/JITASM.cpp @@ -231,6 +231,11 @@ void* jit_runtime_base::_add(asmjit::CodeHolder* code, usz align) noexcept for (asmjit::Section* section : code->_sections) { + if (section->offset() + section->bufferSize() > utils::align(codeSize, align)) + { + fmt::throw_exception("CodeHolder section exceeds range: Section->offset: 0x%x, Section->bufferSize: 0x%x, alloted-memory=0x%x", section->offset(), section->bufferSize(), utils::align(codeSize, align)); + } + std::memcpy(p + section->offset(), section->data(), section->bufferSize()); } }