From 4c6bfb8b784a0e742b557656dc4cb04fe7fdb576 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 16 Nov 2021 22:03:34 +0100 Subject: [PATCH] Fixed a few issues reported by UBSan. --- es-app/src/CollectionSystemsManager.cpp | 3 ++- es-app/src/CollectionSystemsManager.h | 7 +++++++ es-app/src/scrapers/Scraper.h | 11 ++++++++--- es-core/src/components/BadgeComponent.cpp | 11 ++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 388ee5c1d..e712d444f 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -907,10 +907,11 @@ std::vector CollectionSystemsManager::getUnusedSystemsFromTheme() SystemData* CollectionSystemsManager::addNewCustomCollection(const std::string& name) { - CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName]; + CollectionSystemDecl decl = {mCollectionSystemDeclsIndex[myCollectionsName]}; decl.themeFolder = name; decl.name = name; decl.fullName = name; + decl.isCustom = true; return createNewCollectionEntry(name, decl, true, true); } diff --git a/es-app/src/CollectionSystemsManager.h b/es-app/src/CollectionSystemsManager.h index 176f19831..48391a95a 100644 --- a/es-app/src/CollectionSystemsManager.h +++ b/es-app/src/CollectionSystemsManager.h @@ -49,6 +49,13 @@ struct CollectionSystemDecl { }; struct CollectionSystemData { + CollectionSystemData() + : system{nullptr} + , decl{} + , isEnabled{false} + , isPopulated{false} + { + } SystemData* system; CollectionSystemDecl decl; bool isEnabled; diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index 81dde8c60..61c405cff 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -42,6 +42,11 @@ struct ScraperSearchParams { struct ScraperSearchResult { ScraperSearchResult() : mdl(GAME_METADATA) + , scraperRequestAllowance{0} + , mediaURLFetch{NOT_STARTED} + , thumbnailDownloadStatus{NOT_STARTED} + , mediaFilesDownloadStatus{NOT_STARTED} + , savedNewMedia{false} { } @@ -52,9 +57,9 @@ struct ScraperSearchResult { // within a given time period. unsigned int scraperRequestAllowance; - enum downloadStatus mediaURLFetch = NOT_STARTED; - enum downloadStatus thumbnailDownloadStatus = NOT_STARTED; - enum downloadStatus mediaFilesDownloadStatus = NOT_STARTED; + enum downloadStatus mediaURLFetch; + enum downloadStatus thumbnailDownloadStatus; + enum downloadStatus mediaFilesDownloadStatus; std::string thumbnailImageData; // Thumbnail cache, this will contain the entire image. std::string thumbnailImageUrl; diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index f4b21c7a4..182e156e1 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -94,7 +94,8 @@ void BadgeComponent::setBadges(const std::vector& badges) // Save the visibility status to know whether any badges changed. for (auto& item : mFlexboxItems) { prevVisibility[item.label] = item.visible; - prevController[item.label] = item.overlayImage.getTexture()->getTextureFilePath(); + if (item.overlayImage.getTexture() != nullptr) + prevController[item.label] = item.overlayImage.getTexture()->getTextureFilePath(); item.visible = false; } @@ -112,8 +113,12 @@ void BadgeComponent::setBadges(const std::vector& badges) continue; it->visible = true; - if (badge.gameController != "" && - badge.gameController != it->overlayImage.getTexture()->getTextureFilePath()) { + + std::string texturePath; + if (it->overlayImage.getTexture() != nullptr) + texturePath = it->overlayImage.getTexture()->getTextureFilePath(); + + if (badge.gameController != "" && badge.gameController != texturePath) { auto it2 = std::find_if(sGameControllers.begin(), sGameControllers.end(), [badge](GameControllers gameController) {