mirror of https://github.com/AxioDL/metaforce.git
Cache decompression error handling
This commit is contained in:
parent
4e8eb5b0ea
commit
30dabe5267
|
@ -1 +1 @@
|
||||||
Subproject commit 55be829acae46ba894cfe2448004c621992b5010
|
Subproject commit cb2b33a42b61f00348e04cb9c5e2f3a12a8f46f0
|
|
@ -218,13 +218,13 @@ ShaderCachedData ShaderCacheManager::lookupData(const Hash& hash)
|
||||||
{
|
{
|
||||||
auto search = m_entryLookup.find(hash);
|
auto search = m_entryLookup.find(hash);
|
||||||
if (search == m_entryLookup.cend())
|
if (search == m_entryLookup.cend())
|
||||||
return ShaderCachedData();
|
return {};
|
||||||
|
|
||||||
const IndexEntry& ent = m_entries[search->second];
|
const IndexEntry& ent = m_entries[search->second];
|
||||||
if (ent.m_compOffset + ent.m_compSize > m_datFr.length())
|
if (ent.m_compOffset + ent.m_compSize > m_datFr.length())
|
||||||
{
|
{
|
||||||
Log.report(logvisor::Warning, "shader cache not long enough to read entry, might be corrupt");
|
Log.report(logvisor::Warning, "shader cache not long enough to read entry, might be corrupt");
|
||||||
return ShaderCachedData();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* File-streamed decompression */
|
/* File-streamed decompression */
|
||||||
|
@ -240,7 +240,12 @@ ShaderCachedData ShaderCacheManager::lookupData(const Hash& hash)
|
||||||
z.avail_in = std::min(size_t(2048), size_t(ent.m_compSize - z.total_in));
|
z.avail_in = std::min(size_t(2048), size_t(ent.m_compSize - z.total_in));
|
||||||
m_datFr.readUBytesToBuf(compDat, z.avail_in);
|
m_datFr.readUBytesToBuf(compDat, z.avail_in);
|
||||||
z.next_in = compDat;
|
z.next_in = compDat;
|
||||||
inflate(&z, Z_NO_FLUSH);
|
int ret = inflate(&z, Z_NO_FLUSH);
|
||||||
|
if (ret != Z_OK)
|
||||||
|
{
|
||||||
|
inflateEnd(&z);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
inflateEnd(&z);
|
inflateEnd(&z);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue