From bbd34ae7e7f46ee0813a1dc77b5f788bb8a22a1d Mon Sep 17 00:00:00 2001 From: Dima Date: Tue, 29 Nov 2022 10:14:43 +0300 Subject: [PATCH] Validate if entries are not empty before using Should fix saving problem in Baldur's Gate: Dark Alliance II at least --- .../cpp/skyline/services/fssrv/IDirectory.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp index 75c7c681..d4f84fa5 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp @@ -28,17 +28,18 @@ namespace skyline::service::fssrv { auto outputEntries{request.outputBuf.at(0).cast()}; size_t i{}; - for (; i < std::min(entries.size() - remainingReadCount, outputEntries.size()); i++) { - auto &entry{entries.at(i)}; + if (!entries.empty()) + for (; i < std::min(entries.size() - remainingReadCount, outputEntries.size()); i++) { + auto &entry{entries.at(i)}; - outputEntries[i] = { - .type = entry.type, - .attributes.directory = (entry.type == vfs::Directory::EntryType::Directory), - .size = entry.size, - }; + outputEntries[i] = { + .type = entry.type, + .attributes.directory = (entry.type == vfs::Directory::EntryType::Directory), + .size = entry.size, + }; - span(outputEntries[i].name).copy_from(entry.name); - } + span(outputEntries[i].name).copy_from(entry.name); + } remainingReadCount += i; response.Push(i);