From d1c22f7dd6aa80c4072e58a760583a97140a9d83 Mon Sep 17 00:00:00 2001 From: goat Date: Tue, 20 Jun 2023 19:35:59 +0200 Subject: [PATCH] fix: guard against CommandInfo, Manifest ever becoming null --- .../Windows/PluginInstaller/PluginInstallerWindow.cs | 5 ++++- Dalamud/Plugin/Internal/Types/LocalPlugin.cs | 2 +- Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 7679212e6..be27768be 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -2174,7 +2174,10 @@ internal class PluginInstallerWindow : Window, IDisposable if (plugin.IsLoaded) { var commands = commandManager.Commands - .Where(cInfo => cInfo.Value.ShowInHelp && cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName) + .Where(cInfo => + cInfo.Value != null && + cInfo.Value.ShowInHelp && + cInfo.Value.LoaderAssemblyName == plugin.Manifest.InternalName) .ToArray(); if (commands.Any()) diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 062fc94f1..1af2165da 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -630,7 +630,7 @@ internal class LocalPlugin : IDisposable if (manifest.Exists) { // var isDisabled = this.IsDisabled; // saving the internal state because it could have been deleted - this.Manifest = LocalPluginManifest.Load(manifest); + this.Manifest = LocalPluginManifest.Load(manifest) ?? throw new Exception("Could not reload manifest."); // this.Manifest.Disabled = isDisabled; this.SaveManifest(); diff --git a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs index 8a21328c5..e142f9cb0 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs @@ -76,7 +76,7 @@ internal record LocalPluginManifest : PluginManifest /// /// Path to the manifest. /// A object. - public static LocalPluginManifest Load(FileInfo manifestFile) => JsonConvert.DeserializeObject(File.ReadAllText(manifestFile.FullName))!; + public static LocalPluginManifest? Load(FileInfo manifestFile) => JsonConvert.DeserializeObject(File.ReadAllText(manifestFile.FullName)); /// /// A standardized way to get the plugin DLL name that should accompany a manifest file. May not exist.