From 057df28d1b5b5e6e3a61fae1b63434d80654255c Mon Sep 17 00:00:00 2001 From: chibidev Date: Sat, 29 Jul 2017 13:20:10 +0200 Subject: [PATCH] Fixing a null exception when searching AnimeTosho AnimeTosho failed to populate the Origin field of the results when searching thereby creating an issue upon creating the proxy link. This was mainly because an IEnumerable can contain a deferred LINQ query as well (e.g. in the case of AnimeTosho a Select) that will re-execute every single time. So when iterating over IEnumerables we cannot really pose any assumption on what we are dealing with, so either explicitly force an execution (e.g. via ToList), or use LINQ queries as well. Since the second is probably more performant, let's stick with that. --- src/Jackett/Indexers/BaseIndexer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Jackett/Indexers/BaseIndexer.cs b/src/Jackett/Indexers/BaseIndexer.cs index 4ca7bedf4..e9e70d201 100644 --- a/src/Jackett/Indexers/BaseIndexer.cs +++ b/src/Jackett/Indexers/BaseIndexer.cs @@ -218,10 +218,11 @@ namespace Jackett.Indexers { var results = await PerformQuery(query); results = FilterResults(query, results); - foreach (var result in results) + results = results.Select(r => { - result.Origin = this; - } + r.Origin = this; + return r; + }); return results; }