From ec38bc7f3d8cc124a69d843962a78b807d5f82db Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Wed, 17 Jul 2024 14:37:55 +0200 Subject: [PATCH] artic base: Fix issue when 0 bytes are read from file --- src/core/file_sys/archive_artic.cpp | 9 +++++---- src/core/file_sys/artic_cache.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/file_sys/archive_artic.cpp b/src/core/file_sys/archive_artic.cpp index ee36a1cae..a4eb4a599 100644 --- a/src/core/file_sys/archive_artic.cpp +++ b/src/core/file_sys/archive_artic.cpp @@ -405,11 +405,12 @@ ResultVal ArticFileBackend::Read(u64 offset, std::size_t length, u8 return res; auto read_buff = resp->GetResponseBuffer(0); - if (!read_buff.has_value()) - return Result(-1); - size_t actually_read = read_buff->second; + size_t actually_read = 0; + if (read_buff.has_value()) { + actually_read = read_buff->second; + memcpy(buffer + read_amount, read_buff->first, actually_read); + } - memcpy(buffer + read_amount, read_buff->first, actually_read); read_amount += actually_read; if (actually_read != to_read) break; diff --git a/src/core/file_sys/artic_cache.cpp b/src/core/file_sys/artic_cache.cpp index b5c963495..1aa770e93 100644 --- a/src/core/file_sys/artic_cache.cpp +++ b/src/core/file_sys/artic_cache.cpp @@ -200,11 +200,12 @@ ResultVal ArticCache::ReadFromArtic(s32 file_handle, u8* buffer, size_t return res; auto read_buff = resp->GetResponseBuffer(0); - if (!read_buff.has_value()) - return Result(-1); - size_t actually_read = read_buff->second; + size_t actually_read = 0; + if (read_buff.has_value()) { + actually_read = read_buff->second; + memcpy(buffer + read_amount, read_buff->first, actually_read); + } - memcpy(buffer + read_amount, read_buff->first, actually_read); read_amount += actually_read; if (actually_read != to_read) break;