From 34371c070c8820c66ad31b2d08a0839266ef9e0e Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Thu, 9 Feb 2023 13:31:36 +0000 Subject: [PATCH] Mcd-Folder: Prevent crash trying to delete non-existent node. --- pcsx2/MemoryCardFolder.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pcsx2/MemoryCardFolder.cpp b/pcsx2/MemoryCardFolder.cpp index 63bd274c38..124194de1b 100644 --- a/pcsx2/MemoryCardFolder.cpp +++ b/pcsx2/MemoryCardFolder.cpp @@ -1919,10 +1919,13 @@ void FolderMemoryCard::DeleteFromIndex(const std::string& filePath, const std::s if (yaml.has_value() && !yaml.value().empty()) { ryml::NodeRef index = yaml.value().rootref(); - index.remove_child(c4::csubstr(entry.data(), entry.length())); - - // Write out the changes - SaveYAMLToFile(indexName.c_str(), index); + + if (index.has_child(c4::csubstr(entry.data(), entry.length()))) + { + index.remove_child(c4::csubstr(entry.data(), entry.length())); + // Write out the changes + SaveYAMLToFile(indexName.c_str(), index); + } } }