From e129a06436fc8a706525426abf17e1c2fd04a19b Mon Sep 17 00:00:00 2001 From: Geordie Date: Thu, 27 Oct 2022 02:30:44 +1000 Subject: [PATCH] MemoryCard: Fix a crash that happens when copying from one card to a folder memory card via BIOS. (#6746) This fixes a crash that happens if you attempt to copy from one memory card to a formatted folder memory card. --- pcsx2/MemoryCardFolder.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pcsx2/MemoryCardFolder.cpp b/pcsx2/MemoryCardFolder.cpp index 49e94930969a6..5ef1e261411fb 100644 --- a/pcsx2/MemoryCardFolder.cpp +++ b/pcsx2/MemoryCardFolder.cpp @@ -492,7 +492,7 @@ bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const std: if (file.m_isFile) { // don't load files in the root dir if we're filtering; no official software stores files there - if (enableFiltering && parent == nullptr) + if (parent == nullptr) { continue; } @@ -2072,7 +2072,15 @@ void FileAccessHelper::WriteIndex(const std::string& baseFolderName, MemoryCardF pxAssert(entry->IsFile()); std::string folderName(baseFolderName); - parent->GetPath(&folderName); + if (parent != nullptr) + { + parent->GetPath(&folderName); + } + else + { + Console.Warning(fmt::format("(FileAccesHelper::WriteIndex()) '{}' has null parent",Path::Combine(baseFolderName,(const char*)entry->entry.data.name))); + } + char cleanName[sizeof(entry->entry.data.name)]; memcpy(cleanName, (const char*)entry->entry.data.name, sizeof(cleanName)); FileAccessHelper::CleanMemcardFilename(cleanName);