PPU LLVM: fix crash on damaged cache files

This commit is contained in:
Nekotekina 2020-04-07 16:26:22 +03:00
parent 91d80aa7b9
commit 6c8d844ec5

View File

@ -965,6 +965,11 @@ public:
std::vector<uchar> gz = cached.to_vector<uchar>();
std::vector<uchar> out;
z_stream zs{};
if (gz.empty()) [[unlikely]]
{
return nullptr;
}
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
@ -1015,6 +1020,11 @@ public:
if (fs::file cached{path, fs::read})
{
if (cached.size() == 0) [[unlikely]]
{
return nullptr;
}
auto buf = llvm::WritableMemoryBuffer::getNewUninitMemBuffer(cached.size());
cached.read(buf->getBufferStart(), buf->getBufferSize());
return buf;
@ -1208,6 +1218,11 @@ bool jit_compiler::check(const std::string& path)
{
return true;
}
if (fs::remove_file(path))
{
jit_log.error("ObjectCache: Removed damaged file: %s", path);
}
}
return false;