From c69f2d78105b702e8e52f85f02fff4551ce45880 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Sun, 15 Oct 2023 03:40:08 -0400 Subject: [PATCH] Fix ArgumentOutOfRangeException when loading information from chat files with less than 2 comments --- TwitchDownloaderWPF/PageChatUpdate.xaml.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs index 0acbd49e..308f5ea5 100644 --- a/TwitchDownloaderWPF/PageChatUpdate.xaml.cs +++ b/TwitchDownloaderWPF/PageChatUpdate.xaml.cs @@ -67,7 +67,10 @@ private async void btnBrowse_Click(object sender, RoutedEventArgs e) try { ChatJsonInfo = await ChatJson.DeserializeAsync(InputFile, true, false, CancellationToken.None); - ChatJsonInfo.comments.RemoveRange(1, ChatJsonInfo.comments.Count - 2); + if (ChatJsonInfo.comments.Count > 2) + { + ChatJsonInfo.comments.RemoveRange(1, ChatJsonInfo.comments.Count - 2); + } GC.Collect(); } catch (Exception ex)