libstrat: Allow nullptr buffers if 0 size. (closes #255)

This commit is contained in:
Michael Scire
2018-11-04 21:52:26 -08:00
parent 78a47dba6d
commit 3ed239296a
2 changed files with 7 additions and 2 deletions

View File

@@ -46,6 +46,11 @@ LayeredRomFS::LayeredRomFS(std::shared_ptr<RomInterfaceStorage> s_r, std::shared
Result LayeredRomFS::Read(void *buffer, size_t size, u64 offset) {
/* Size zero reads should always succeed. */
if (size == 0) {
return 0;
}
/* Validate size. */
u64 virt_size = (*this->p_source_infos)[this->p_source_infos->size() - 1].virtual_offset + (*this->p_source_infos)[this->p_source_infos->size() - 1].size;
if (offset >= virt_size) {