LLVM: Fix nullptr deref when accessing broken cache files

This commit is contained in:
Elad Ashkenazi 2024-05-29 17:43:23 +03:00
parent a6b2bf69f1
commit c556322fc5

View File

@ -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<llvm::object::ObjectFile>(std::move(*object_file), std::move(cache)));