diff --git a/Utilities/JITASM.cpp b/Utilities/JITASM.cpp index 642eb631bc4f..493380c600d2 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()); } }