From 3c373c8aa82a6178993f8181c4621540141eb49e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 3 Jan 2020 23:27:39 +0100 Subject: [PATCH] WIA: Treat groups with size 0 as containing only zeroes --- Source/Core/DiscIO/WIABlob.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index 6c56af5ad1..c6c1cae22e 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -246,12 +246,20 @@ 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; - const u64 group_offset_in_file = static_cast(Common::swap32(group.data_offset)) << 2; const u64 bytes_to_read = std::min(chunk_size - offset_in_group, *size); - if (!ReadCompressedData(chunk_size, group_offset_in_file, Common::swap32(group.data_size), - offset_in_group, bytes_to_read, *out_ptr, exception_list)) + const u32 group_data_size = Common::swap32(group.data_size); + if (group_data_size == 0) { - return false; + std::memset(*out_ptr, 0, bytes_to_read); + } + else + { + const u64 group_offset_in_file = static_cast(Common::swap32(group.data_offset)) << 2; + if (!ReadCompressedData(chunk_size, group_offset_in_file, group_data_size, offset_in_group, + bytes_to_read, *out_ptr, exception_list)) + { + return false; + } } *offset += bytes_to_read;