From ef9016e363f7f8319b32107e9aa60a49cc13d9a8 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sat, 19 Sep 2015 13:01:19 +0300 Subject: [PATCH] folderMemoryCard: hack - don't hang PCSX2 if a file has zero size I'm not sure if it breaks the state of the folderMemoryCard (FMC) or not, but at least it doesn't hang PCSX2. Might need followup to make sure the state ends up valid. --- pcsx2/gui/MemoryCardFolder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pcsx2/gui/MemoryCardFolder.cpp b/pcsx2/gui/MemoryCardFolder.cpp index 164490e1d9..6205d07dc9 100644 --- a/pcsx2/gui/MemoryCardFolder.cpp +++ b/pcsx2/gui/MemoryCardFolder.cpp @@ -413,6 +413,11 @@ bool FolderMemoryCard::AddFile( MemoryCardFileEntry* const dirEntry, const wxStr // make sure we have enough space on the memcard to hold the data const u32 clusterSize = m_superBlock.data.pages_per_cluster * m_superBlock.data.page_len; const u32 filesize = file.Length(); + if (!filesize) { + Console.Error(L"(MCDF) Empty file. Aborting."); + file.Close(); + return false; + } const u32 countClusters = ( filesize % clusterSize ) != 0 ? ( filesize / clusterSize + 1 ) : ( filesize / clusterSize ); const u32 newNeededClusters = ( dirEntry->entry.data.length % 2 ) == 0 ? countClusters + 1 : countClusters; if ( newNeededClusters > GetAmountFreeDataClusters() ) {