Mcd-Folder: Prevent crash trying to delete non-existent node.

This commit is contained in:
refractionpcsx2 2023-02-09 13:31:36 +00:00
parent d6099dd263
commit 34371c070c
1 changed files with 7 additions and 4 deletions

View File

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