From c556322fc52ecaa8d65b5dda5ae625cd8e2fe273 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Wed, 29 May 2024 17:43:23 +0300 Subject: [PATCH] LLVM: Fix nullptr deref when accessing broken cache files --- Utilities/JITLLVM.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Utilities/JITLLVM.cpp b/Utilities/JITLLVM.cpp index e514f5c62c..e35f5f493a 100644 --- a/Utilities/JITLLVM.cpp +++ b/Utilities/JITLLVM.cpp @@ -388,6 +388,7 @@ public: auto buf = llvm::WritableMemoryBuffer::getNewUninitMemBuffer(cached.size()); cached.read(buf->getBufferStart(), buf->getBufferSize()); + return buf; } @@ -615,6 +616,12 @@ void jit_compiler::add(const std::string& path) { auto cache = ObjectCache::load(path); + if (!cache) + { + jit_log.error("ObjectCache: Failed to read file. (path='%s', error=%s)", path, fs::g_tls_error); + return; + } + if (auto object_file = llvm::object::ObjectFile::createObjectFile(*cache)) { m_engine->addObjectFile(llvm::object::OwningBinary(std::move(*object_file), std::move(cache)));