am: Correct ListDLCContentInfos index bounds.

This commit is contained in:
Steveice10 2018-08-04 01:24:36 -07:00
parent d93ed644f6
commit 4c3961d5dd

View File

@ -592,9 +592,10 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
u32 copied = 0; u32 copied = 0;
FileSys::TitleMetadata tmd; FileSys::TitleMetadata tmd;
if (tmd.Load(tmd_path) == Loader::ResultStatus::Success) { if (tmd.Load(tmd_path) == Loader::ResultStatus::Success) {
copied = std::min(content_count, static_cast<u32>(tmd.GetContentCount())); u32 end_index =
std::min(start_index + content_count, static_cast<u32>(tmd.GetContentCount()));
std::size_t write_offset = 0; std::size_t write_offset = 0;
for (u32 i = start_index; i < start_index + copied; i++) { for (u32 i = start_index; i < end_index; i++) {
std::shared_ptr<FileUtil::IOFile> romfs_file; std::shared_ptr<FileUtil::IOFile> romfs_file;
u64 romfs_offset = 0; u64 romfs_offset = 0;
@ -612,6 +613,7 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) {
content_info_out.Write(&content_info, write_offset, sizeof(ContentInfo)); content_info_out.Write(&content_info, write_offset, sizeof(ContentInfo));
write_offset += sizeof(ContentInfo); write_offset += sizeof(ContentInfo);
copied++;
} }
} }