diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2020-04-24 10:42:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-24 10:42:46 +0200 |
| commit | 7e94d6ed375cecae59717626f6ab1b32674a15dc (patch) | |
| tree | d06db2d36addd6e0bed4f6871b1c3b84e9ac3bf9 /Source/Core/DiscIO/CompressedBlob.cpp | |
| parent | 703f7d4fc014717f13bbb849057e3e7e33b48477 (diff) | |
| parent | 19e9a9c94543701bdff6831c26ee6daff0acb73f (diff) | |
Merge pull request #8740 from JosJuice/fix-decompress
DiscIO: Fix decompressing writing the wrong number of bytes sometimes
Diffstat (limited to 'Source/Core/DiscIO/CompressedBlob.cpp')
| -rw-r--r-- | Source/Core/DiscIO/CompressedBlob.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp index 37af397b38..5248170683 100644 --- a/Source/Core/DiscIO/CompressedBlob.cpp +++ b/Source/Core/DiscIO/CompressedBlob.cpp @@ -371,7 +371,6 @@ bool DecompressBlobToFile(const std::string& infile_path, const std::string& out const CompressedBlobHeader& header = reader->GetHeader(); static const size_t BUFFER_BLOCKS = 32; size_t buffer_size = header.block_size * BUFFER_BLOCKS; - size_t last_buffer_size = header.block_size * (header.num_blocks % BUFFER_BLOCKS); std::vector<u8> buffer(buffer_size); u32 num_buffers = (header.num_blocks + BUFFER_BLOCKS - 1) / BUFFER_BLOCKS; int progress_monitor = std::max<int>(1, num_buffers / 100); @@ -389,8 +388,9 @@ bool DecompressBlobToFile(const std::string& infile_path, const std::string& out break; } } - const size_t sz = i == num_buffers - 1 ? last_buffer_size : buffer_size; - reader->Read(i * buffer_size, sz, buffer.data()); + const u64 inpos = i * buffer_size; + const u64 sz = std::min<u64>(buffer_size, header.data_size - inpos); + reader->Read(inpos, sz, buffer.data()); if (!outfile.WriteBytes(buffer.data(), sz)) { PanicAlertT("Failed to write the output file \"%s\".\n" |
