diff --git a/es-app/src/GamelistFileParser.cpp b/es-app/src/GamelistFileParser.cpp index 089a65876..f3c316860 100644 --- a/es-app/src/GamelistFileParser.cpp +++ b/es-app/src/GamelistFileParser.cpp @@ -38,6 +38,19 @@ namespace GamelistFileParser bool found {false}; while (path_it != pathList.end()) { + // Workaround for an extremely rare issue that can basically only happen if a dot (.) + // has been defined as a valid extension for the system (meaning extension-less files + // are loaded), in combination with the "Only show ROMs from gamelist.xml files" option + // being enabled and a stale entry being present in the gamelist.xml file that perfectly + // matches a folder which is actually in use. The workaround is not a perfect solution + // but it at least prevents the application from crashing. + if (treeNode->getType() != FOLDER) { + LOG(LogWarning) + << "Invalid gamelist entry caused by folder having the same name as a stale " + << "extension-less game file (this may cause undefined behavior):"; + return nullptr; + } + const std::unordered_map& children { treeNode->getChildrenByFilename()}; diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 001f644f4..1102f2dcf 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -319,7 +319,8 @@ bool SystemData::populateFolder(FileData* folder) isGame = false; if (std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(), - extension) != mEnvData->mSearchExtensions.cend()) { + extension) != mEnvData->mSearchExtensions.cend() && + !(isDirectory && extension == ".")) { FileData* newGame {new FileData(GAME, filePath, mEnvData, this)}; // If adding a configured file extension to a directory it will get interpreted as @@ -327,7 +328,7 @@ bool SystemData::populateFolder(FileData* folder) // entries or for emulators that can get directories passed to them as command line // parameters instead of regular files. In these instances we remove the extension // from the metadata name so it does not show up in the gamelists and similar. - if (isDirectory) { + if (isDirectory && extension != ".") { const std::string& folderName {newGame->metadata.get("name")}; newGame->metadata.set( "name", folderName.substr(0, folderName.length() - extension.length()));