summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/CompressedBlob.cpp
diff options
context:
space:
mode:
authorEmptyChaos <EmptyChaos@users.noreply.github.com>2016-04-26 11:24:08 +0000
committerEmptyChaos <EmptyChaos@users.noreply.github.com>2016-04-26 21:24:08 +1000
commit97d570f0c9650a25185fe187b97731d30d086fbb (patch)
tree97935e71586bda7d069f241ce0be43df25903ce3 /Source/Core/DiscIO/CompressedBlob.cpp
parentbdb9da21041fdcefa4504c28259647eea910e36c (diff)
DriveReader: Fix View > Show Drives
DriveReader::m_size was never initialized which was indirectly causing CGameListCtrl to crash Dolphin when it tried to insert a character at a negative index in a string. Reading one sector at a time is very inefficient and appears to be causing timing issues during boot so SectorReader has been enhanced to support batching. SectorReader has been given a working cache system.
Diffstat (limited to 'Source/Core/DiscIO/CompressedBlob.cpp')
-rw-r--r--Source/Core/DiscIO/CompressedBlob.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp
index e41642d483..3e99890c81 100644
--- a/Source/Core/DiscIO/CompressedBlob.cpp
+++ b/Source/Core/DiscIO/CompressedBlob.cpp
@@ -79,7 +79,7 @@ u64 CompressedBlobReader::GetBlockCompressedSize(u64 block_num) const
return 0;
}
-void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
+bool CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
{
bool uncompressed = false;
u32 comp_block_size = (u32)GetBlockCompressedSize(block_num);
@@ -97,7 +97,13 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
memset(&m_zlib_buffer[comp_block_size], 0, m_zlib_buffer.size() - comp_block_size);
m_file.Seek(offset, SEEK_SET);
- m_file.ReadBytes(m_zlib_buffer.data(), comp_block_size);
+ if (!m_file.ReadBytes(m_zlib_buffer.data(), comp_block_size))
+ {
+ PanicAlertT("The disc image \"%s\" is truncated, some of the data is missing.",
+ m_file_name.c_str());
+ m_file.Clear();
+ return false;
+ }
// First, check hash.
u32 block_hash = HashAdler32(m_zlib_buffer.data(), comp_block_size);
@@ -133,8 +139,12 @@ void CompressedBlobReader::GetBlock(u64 block_num, u8 *out_ptr)
}
inflateEnd(&z);
if (uncomp_size != m_header.block_size)
+ {
PanicAlert("Wrong block size");
+ return false;
+ }
}
+ return true;
}
bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type,