1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

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