diff options
| author | 2023-12-01 23:39:48 -0500 | |
|---|---|---|
| committer | 2023-12-01 23:39:48 -0500 | |
| commit | 45b6161582e0dd5b54fd3c06b3176f5b32ca10aa (patch) | |
| tree | eeef2fc18a459377ab40e9fb36810b08fd31c11b /src/core/file_sys/romfs.cpp | |
| parent | Merge pull request #12255 from german77/amiibo (diff) | |
| download | yuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.tar.gz yuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.tar.xz yuzu-45b6161582e0dd5b54fd3c06b3176f5b32ca10aa.zip | |
file_sys: handle null romfs
Diffstat (limited to 'src/core/file_sys/romfs.cpp')
| -rw-r--r-- | src/core/file_sys/romfs.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 1eb1f439a..6de2103a0 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "common/assert.h" | ||
| 6 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 7 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 8 | #include "common/swap.h" | 9 | #include "common/swap.h" |
| @@ -101,24 +102,30 @@ void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size | |||
| 101 | } // Anonymous namespace | 102 | } // Anonymous namespace |
| 102 | 103 | ||
| 103 | VirtualDir ExtractRomFS(VirtualFile file) { | 104 | VirtualDir ExtractRomFS(VirtualFile file) { |
| 105 | auto root_container = std::make_shared<VectorVfsDirectory>(); | ||
| 106 | if (!file) { | ||
| 107 | return root_container; | ||
| 108 | } | ||
| 109 | |||
| 104 | RomFSHeader header{}; | 110 | RomFSHeader header{}; |
| 105 | if (file->ReadObject(&header) != sizeof(RomFSHeader)) | 111 | if (file->ReadObject(&header) != sizeof(RomFSHeader)) { |
| 106 | return nullptr; | 112 | return root_container; |
| 113 | } | ||
| 107 | 114 | ||
| 108 | if (header.header_size != sizeof(RomFSHeader)) | 115 | if (header.header_size != sizeof(RomFSHeader)) { |
| 109 | return nullptr; | 116 | return root_container; |
| 117 | } | ||
| 110 | 118 | ||
| 111 | const u64 file_offset = header.file_meta.offset; | 119 | const u64 file_offset = header.file_meta.offset; |
| 112 | const u64 dir_offset = header.directory_meta.offset; | 120 | const u64 dir_offset = header.directory_meta.offset; |
| 113 | 121 | ||
| 114 | auto root_container = std::make_shared<VectorVfsDirectory>(); | ||
| 115 | |||
| 116 | ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container); | 122 | ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container); |
| 117 | 123 | ||
| 118 | if (auto root = root_container->GetSubdirectory(""); root) { | 124 | if (auto root = root_container->GetSubdirectory(""); root) { |
| 119 | return std::make_shared<CachedVfsDirectory>(std::move(root)); | 125 | return std::make_shared<CachedVfsDirectory>(std::move(root)); |
| 120 | } | 126 | } |
| 121 | 127 | ||
| 128 | ASSERT(false); | ||
| 122 | return nullptr; | 129 | return nullptr; |
| 123 | } | 130 | } |
| 124 | 131 | ||