From 51e2e084afeef65b6906834f8c1ce7e16741fba5 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 9 Feb 2020 17:05:45 +0100 Subject: [PATCH] Added try-catch for DateTime.TryParse edgecase closes #3518 --- .../SeriesStats/SeasonStatistics.cs | 20 +++++++++++++++++-- .../SeriesStats/SeriesStatistics.cs | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs b/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs index 0eb2d63c0..9542b0d0a 100644 --- a/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs +++ b/src/NzbDrone.Core/SeriesStats/SeasonStatistics.cs @@ -21,7 +21,15 @@ namespace NzbDrone.Core.SeriesStats { DateTime nextAiring; - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; + try + { + if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; + } + catch (ArgumentOutOfRangeException) + { + // GHI 3518: Can throw on mono (6.x?) despite being a Try* + return null; + } return nextAiring; } @@ -33,7 +41,15 @@ namespace NzbDrone.Core.SeriesStats { DateTime previousAiring; - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; + try + { + if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; + } + catch (ArgumentOutOfRangeException) + { + // GHI 3518: Can throw on mono (6.x?) despite being a Try* + return null; + } return previousAiring; } diff --git a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs b/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs index 25a82d68f..363d1f346 100644 --- a/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs +++ b/src/NzbDrone.Core/SeriesStats/SeriesStatistics.cs @@ -21,7 +21,15 @@ namespace NzbDrone.Core.SeriesStats { DateTime nextAiring; - if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; + try + { + if (!DateTime.TryParse(NextAiringString, out nextAiring)) return null; + } + catch (ArgumentOutOfRangeException) + { + // GHI 3518: Can throw on mono (6.x?) despite being a Try* + return null; + } return nextAiring; } @@ -33,7 +41,15 @@ namespace NzbDrone.Core.SeriesStats { DateTime previousAiring; - if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; + try + { + if (!DateTime.TryParse(PreviousAiringString, out previousAiring)) return null; + } + catch (ArgumentOutOfRangeException) + { + // GHI 3518: Can throw on mono (6.x?) despite being a Try* + return null; + } return previousAiring; }