diff options
| author | 2019-04-10 12:28:32 -0400 | |
|---|---|---|
| committer | 2019-09-21 16:43:10 -0400 | |
| commit | 06db4d94fde745c39326fe5564b93348610a5674 (patch) | |
| tree | a336102dfda065f9463a621fa22478dfecb452b0 /src/core/file_sys | |
| parent | registered_cache: Process *.cnmt.nca files (diff) | |
| download | yuzu-06db4d94fde745c39326fe5564b93348610a5674.tar.gz yuzu-06db4d94fde745c39326fe5564b93348610a5674.tar.xz yuzu-06db4d94fde745c39326fe5564b93348610a5674.zip | |
patch_manager: Add error checking to load dir to prevent crashes
Prevents a crash if the load dir would be nullptr, instead logs an error and returns appropriately.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index a8f80e2c6..0a4f0ea74 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -187,6 +187,11 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso, const std::st | |||
| 187 | LOG_INFO(Loader, "Patching NSO for name={}, build_id={}", name, build_id); | 187 | LOG_INFO(Loader, "Patching NSO for name={}, build_id={}", name, build_id); |
| 188 | 188 | ||
| 189 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 189 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
| 190 | if (load_dir == nullptr) { | ||
| 191 | LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id); | ||
| 192 | return nso; | ||
| 193 | } | ||
| 194 | |||
| 190 | auto patch_dirs = load_dir->GetSubdirectories(); | 195 | auto patch_dirs = load_dir->GetSubdirectories(); |
| 191 | std::sort(patch_dirs.begin(), patch_dirs.end(), | 196 | std::sort(patch_dirs.begin(), patch_dirs.end(), |
| 192 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); | 197 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); |
| @@ -225,6 +230,11 @@ bool PatchManager::HasNSOPatch(const std::array<u8, 32>& build_id_) const { | |||
| 225 | LOG_INFO(Loader, "Querying NSO patch existence for build_id={}", build_id); | 230 | LOG_INFO(Loader, "Querying NSO patch existence for build_id={}", build_id); |
| 226 | 231 | ||
| 227 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 232 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
| 233 | if (load_dir == nullptr) { | ||
| 234 | LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id); | ||
| 235 | return false; | ||
| 236 | } | ||
| 237 | |||
| 228 | auto patch_dirs = load_dir->GetSubdirectories(); | 238 | auto patch_dirs = load_dir->GetSubdirectories(); |
| 229 | std::sort(patch_dirs.begin(), patch_dirs.end(), | 239 | std::sort(patch_dirs.begin(), patch_dirs.end(), |
| 230 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); | 240 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); |
| @@ -259,6 +269,11 @@ static std::optional<CheatList> ReadCheatFileFromFolder(const Core::System& syst | |||
| 259 | std::vector<CheatList> PatchManager::CreateCheatList(const Core::System& system, | 269 | std::vector<CheatList> PatchManager::CreateCheatList(const Core::System& system, |
| 260 | const std::array<u8, 32>& build_id_) const { | 270 | const std::array<u8, 32>& build_id_) const { |
| 261 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 271 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
| 272 | if (load_dir == nullptr) { | ||
| 273 | LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id); | ||
| 274 | return {}; | ||
| 275 | } | ||
| 276 | |||
| 262 | auto patch_dirs = load_dir->GetSubdirectories(); | 277 | auto patch_dirs = load_dir->GetSubdirectories(); |
| 263 | std::sort(patch_dirs.begin(), patch_dirs.end(), | 278 | std::sort(patch_dirs.begin(), patch_dirs.end(), |
| 264 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); | 279 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); |