From 149bda980a67cf8102aa8290334e697af166aac6 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 11 Aug 2018 22:44:50 -0400 Subject: romfs: Remove cyclic shared_ptr leak in romfs code --- src/core/file_sys/romfs.cpp | 8 ++++---- src/core/file_sys/vfs_vector.cpp | 4 ++-- src/core/file_sys/vfs_vector.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index ff3ddb29c..e490c8ace 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -65,7 +65,7 @@ void ProcessFile(VirtualFile file, size_t file_offset, size_t data_offset, u32 t auto entry = GetEntry(file, file_offset + this_file_offset); parent->AddFile(std::make_shared( - file, entry.first.size, entry.first.offset + data_offset, entry.second, parent)); + file, entry.first.size, entry.first.offset + data_offset, entry.second)); if (entry.first.sibling == ROMFS_ENTRY_EMPTY) break; @@ -79,7 +79,7 @@ void ProcessDirectory(VirtualFile file, size_t dir_offset, size_t file_offset, s while (true) { auto entry = GetEntry(file, dir_offset + this_dir_offset); auto current = std::make_shared( - std::vector{}, std::vector{}, parent, entry.second); + std::vector{}, std::vector{}, entry.second); if (entry.first.child_file != ROMFS_ENTRY_EMPTY) { ProcessFile(file, file_offset, data_offset, entry.first.child_file, current); @@ -108,9 +108,9 @@ VirtualDir ExtractRomFS(VirtualFile file) { const u64 file_offset = header.file_meta.offset; const u64 dir_offset = header.directory_meta.offset + 4; - const auto root = + auto root = std::make_shared(std::vector{}, std::vector{}, - file->GetContainingDirectory(), file->GetName()); + file->GetName(), file->GetContainingDirectory()); ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root); diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index fda603960..98e7c4598 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp @@ -8,8 +8,8 @@ namespace FileSys { VectorVfsDirectory::VectorVfsDirectory(std::vector files_, - std::vector dirs_, VirtualDir parent_, - std::string name_) + std::vector dirs_, std::string name_, + VirtualDir parent_) : files(std::move(files_)), dirs(std::move(dirs_)), parent(std::move(parent_)), name(std::move(name_)) {} diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index ba469647b..dc39c9f2f 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h @@ -12,8 +12,8 @@ namespace FileSys { // Vector data is supplied upon construction. struct VectorVfsDirectory : public VfsDirectory { explicit VectorVfsDirectory(std::vector files = {}, - std::vector dirs = {}, VirtualDir parent = nullptr, - std::string name = ""); + std::vector dirs = {}, std::string name = "", + VirtualDir parent = nullptr); std::vector> GetFiles() const override; std::vector> GetSubdirectories() const override; -- cgit v1.2.3