From 3aac1b543fa3f6ed88f64f1b5ff0b29a3056367f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Sep 2013 13:51:38 -0400 Subject: [PATCH] fix null reference issue when checking for updates --- .../Updates/InstallationManager.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs index a47ca4985d..732a108934 100644 --- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs @@ -308,22 +308,26 @@ namespace MediaBrowser.Common.Implementations.Updates protected IEnumerable FilterCatalog(IEnumerable catalog, bool withAutoUpdateEnabled) { - var plugins = _applicationHost.Plugins; + var plugins = _applicationHost.Plugins.ToList(); if (withAutoUpdateEnabled) { - plugins = plugins.Where(p => p.Configuration.EnableAutoUpdate); + plugins = plugins + .Where(p => p.Configuration.EnableAutoUpdate) + .ToList(); } // Figure out what needs to be installed - return plugins.Select(p => + var packages = plugins.Select(p => { var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass); - return latestPluginInfo != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null; + return latestPluginInfo != null && latestPluginInfo.version != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null; - }).Where(p => !CompletedInstallations.Any(i => string.Equals(i.Name, p.name, StringComparison.OrdinalIgnoreCase))) - .Where(p => p != null && !string.IsNullOrWhiteSpace(p.sourceUrl)); + }).Where(i => i != null).ToList(); + + return packages + .Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.Name, p.name, StringComparison.OrdinalIgnoreCase))); } ///