From 4f915760e8a91aacf1c7387289c471fd31d8c40e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 12 Apr 2019 11:27:27 +0200 Subject: [PATCH] Fix importing Wii save files with sizes not divisible by 64 --- Source/Core/Core/HW/WiiSave.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/WiiSave.cpp b/Source/Core/Core/HW/WiiSave.cpp index 575f04a643..0f8d48c77e 100644 --- a/Source/Core/Core/HW/WiiSave.cpp +++ b/Source/Core/Core/HW/WiiSave.cpp @@ -311,17 +311,20 @@ public: std::string{file_hdr.name.data(), strnlen(file_hdr.name.data(), file_hdr.name.size())}; if (type == SaveFile::Type::File) { - const u32 rounded_size = Common::AlignUp(file_hdr.size, BLOCK_SZ); + const u32 size = file_hdr.size; + const u32 rounded_size = Common::AlignUp(size, BLOCK_SZ); const u64 pos = m_file.Tell(); std::array iv = file_hdr.iv; - save_file.data = [this, rounded_size, iv, pos]() mutable -> std::optional> { + save_file.data = [this, size, rounded_size, iv, + pos]() mutable -> std::optional> { std::vector file_data(rounded_size); if (!m_file.Seek(pos, SEEK_SET) || !m_file.ReadBytes(file_data.data(), rounded_size)) return {}; m_iosc.Decrypt(IOS::HLE::IOSC::HANDLE_SD_KEY, iv.data(), file_data.data(), rounded_size, file_data.data(), IOS::PID_ES); + file_data.resize(size); return file_data; }; m_file.Seek(pos + rounded_size, SEEK_SET);