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.
This commit is contained in:
Geordie 2022-10-27 02:30:44 +10:00 committed by GitHub
parent c99714dbb2
commit e129a06436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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);