Skip to content

Commit

Permalink
MemoryCard: Fix a crash that happens when copying from one card to a …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
CakeKing64 authored Oct 26, 2022
1 parent c99714d commit e129a06
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pcsx2/MemoryCardFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e129a06

Please sign in to comment.