Skip to content

Commit 518f723

Browse files
authored
Artic Base: Fix issue when 0 bytes are read from file (#199)
1 parent 959a66d commit 518f723

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Diff for: src/core/file_sys/archive_artic.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,12 @@ ResultVal<std::size_t> ArticFileBackend::Read(u64 offset, std::size_t length, u8
405405
return res;
406406

407407
auto read_buff = resp->GetResponseBuffer(0);
408-
if (!read_buff.has_value())
409-
return Result(-1);
410-
size_t actually_read = read_buff->second;
408+
size_t actually_read = 0;
409+
if (read_buff.has_value()) {
410+
actually_read = read_buff->second;
411+
memcpy(buffer + read_amount, read_buff->first, actually_read);
412+
}
411413

412-
memcpy(buffer + read_amount, read_buff->first, actually_read);
413414
read_amount += actually_read;
414415
if (actually_read != to_read)
415416
break;

Diff for: src/core/file_sys/artic_cache.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ ResultVal<size_t> ArticCache::ReadFromArtic(s32 file_handle, u8* buffer, size_t
200200
return res;
201201

202202
auto read_buff = resp->GetResponseBuffer(0);
203-
if (!read_buff.has_value())
204-
return Result(-1);
205-
size_t actually_read = read_buff->second;
203+
size_t actually_read = 0;
204+
if (read_buff.has_value()) {
205+
actually_read = read_buff->second;
206+
memcpy(buffer + read_amount, read_buff->first, actually_read);
207+
}
206208

207-
memcpy(buffer + read_amount, read_buff->first, actually_read);
208209
read_amount += actually_read;
209210
if (actually_read != to_read)
210211
break;

0 commit comments

Comments
 (0)