diff options
| author | 2022-03-27 17:06:27 -0400 | |
|---|---|---|
| committer | 2022-03-27 17:06:27 -0400 | |
| commit | ea7a0d4652692eb0cd78c721b809d7e0e2563def (patch) | |
| tree | b53945be4101da3b7a1fad8a0ee0f32aec3d6b6e | |
| parent | Merge pull request #8095 from bylaws/master (diff) | |
| download | yuzu-ea7a0d4652692eb0cd78c721b809d7e0e2563def.tar.gz yuzu-ea7a0d4652692eb0cd78c721b809d7e0e2563def.tar.xz yuzu-ea7a0d4652692eb0cd78c721b809d7e0e2563def.zip | |
registered_cache: Prevent nullptr dereference when accumulating files
For whatever reason, nca_file/dir can be nullptr in the list of files/dirs. I have not determined the cause of this yet, so add a nullptr check for these prior to dereferencing them.
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 7a646b5f1..4ada4a69b 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -387,15 +387,17 @@ std::vector<NcaID> RegisteredCache::AccumulateFiles() const { | |||
| 387 | continue; | 387 | continue; |
| 388 | 388 | ||
| 389 | for (const auto& nca_dir : d2_dir->GetSubdirectories()) { | 389 | for (const auto& nca_dir : d2_dir->GetSubdirectories()) { |
| 390 | if (!FollowsNcaIdFormat(nca_dir->GetName())) | 390 | if (nca_dir == nullptr || !FollowsNcaIdFormat(nca_dir->GetName())) { |
| 391 | continue; | 391 | continue; |
| 392 | } | ||
| 392 | 393 | ||
| 393 | ids.push_back(Common::HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20))); | 394 | ids.push_back(Common::HexStringToArray<0x10, true>(nca_dir->GetName().substr(0, 0x20))); |
| 394 | } | 395 | } |
| 395 | 396 | ||
| 396 | for (const auto& nca_file : d2_dir->GetFiles()) { | 397 | for (const auto& nca_file : d2_dir->GetFiles()) { |
| 397 | if (!FollowsNcaIdFormat(nca_file->GetName())) | 398 | if (nca_file == nullptr || !FollowsNcaIdFormat(nca_file->GetName())) { |
| 398 | continue; | 399 | continue; |
| 400 | } | ||
| 399 | 401 | ||
| 400 | ids.push_back( | 402 | ids.push_back( |
| 401 | Common::HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20))); | 403 | Common::HexStringToArray<0x10, true>(nca_file->GetName().substr(0, 0x20))); |