Fixed an issue where attempting to create the system directories with invalid entries in es_systems.xml could crash the application

This commit is contained in:
Leon Styhre 2023-12-25 12:06:31 +01:00
parent cfb71c378f
commit 80a462abb3

View file

@ -1122,6 +1122,18 @@ bool SystemData::createSystemDirectories()
return (std::isspace(character) || character == ',');
}) != platform.cend()};
if (name.empty()) {
LOG(LogError)
<< "A system in the es_systems.xml file has no name defined, skipping entry";
continue;
}
else if (fullname.empty() || path.empty() || extensions.empty() || commands.empty()) {
LOG(LogError) << "System \"" << name
<< "\" is missing the fullname, path, "
"extension, or command tag, skipping entry";
continue;
}
themeFolder = system.child("theme").text().as_string(name.c_str());
// Check that the %ROMPATH% variable is actually used for the path element.
@ -1203,7 +1215,10 @@ bool SystemData::createSystemDirectories()
}
systemInfoFile << "Platform" << (multiplePlatforms ? "s" : "")
<< " (for scraping):" << std::endl;
systemInfoFile << platform << std::endl << std::endl;
if (platform.empty())
systemInfoFile << "None defined" << std::endl << std::endl;
else
systemInfoFile << platform << std::endl << std::endl;
systemInfoFile << "Theme folder:" << std::endl;
systemInfoFile << themeFolder << std::endl;
systemInfoFile.close();