From 1579e061a3111b638c08e927b6416995ac75ec43 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 3 Jan 2020 23:57:35 +0100 Subject: [PATCH] WIA: Correctly handle data with size not divisible by chunk size --- Source/Core/DiscIO/WIABlob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index c6c1cae22e..692462b2af 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -246,6 +246,8 @@ bool WIAFileReader::ReadFromGroups(u64* offset, u64* size, u8** out_ptr, u64 chu const u64 group_offset = data_offset + i * chunk_size; const u64 offset_in_group = *offset - group_offset; + chunk_size = std::min(chunk_size, data_offset + data_size - group_offset); + const u64 bytes_to_read = std::min(chunk_size - offset_in_group, *size); const u32 group_data_size = Common::swap32(group.data_size); if (group_data_size == 0)