From 8f8e893e84bcc5fa5a2ef66785b6c41d42eff8a7 Mon Sep 17 00:00:00 2001 From: Frog Date: Sun, 15 Mar 2026 03:15:17 -0700 Subject: [PATCH] Fix NullReferenceException in EpicStore See #12 - Fix a NullReferenceException that could occur when the Epic GraphQL API returns a partial response with missing fields (Data, Catalog, SearchStore, or CatalogOffers). --- CreamInstaller/Platforms/Epic/EpicStore.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CreamInstaller/Platforms/Epic/EpicStore.cs b/CreamInstaller/Platforms/Epic/EpicStore.cs index 4092277..ebda557 100644 --- a/CreamInstaller/Platforms/Epic/EpicStore.cs +++ b/CreamInstaller/Platforms/Epic/EpicStore.cs @@ -58,9 +58,9 @@ internal static class EpicStore cacheFile.DeleteFile(); } - if (response is null) + if (response is null || response.Data?.Catalog is null) return dlcIds; - List searchStore = [..response.Data.Catalog.SearchStore.Elements]; + List searchStore = [..response.Data.Catalog.SearchStore?.Elements ?? []]; foreach (Element element in searchStore) { string title = element.Title; @@ -81,7 +81,7 @@ internal static class EpicStore dlcIds.Populate(item.Id, title, product, icon, null, element.Items.Length == 1); } - List catalogOffers = [..response.Data.Catalog.CatalogOffers.Elements]; + List catalogOffers = [..response.Data.Catalog.CatalogOffers?.Elements ?? []]; foreach (Element element in catalogOffers) { string title = element.Title; @@ -118,6 +118,7 @@ internal static class EpicStore (string id, string name, string product, string icon, string developer) app = dlcIds[i]; if (app.id != id) continue; + found = true; dlcIds[i] = canOverwrite ? (app.id, title ?? app.name, product ?? app.product, icon ?? app.icon, developer ?? app.developer)