From 943e455cffca5fd6ac535ed6bcc6dd08b424d883 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 20 Sep 2016 15:28:55 -0700 Subject: [PATCH] [DatFile] Add extra precautions for stuff I can't test --- SabreTools.Helper/Objects/Dat/DatFile.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/SabreTools.Helper/Objects/Dat/DatFile.cs b/SabreTools.Helper/Objects/Dat/DatFile.cs index 4adff1ce..5c9825e3 100644 --- a/SabreTools.Helper/Objects/Dat/DatFile.cs +++ b/SabreTools.Helper/Objects/Dat/DatFile.cs @@ -2249,6 +2249,13 @@ namespace SabreTools.Helper List keys = dict.Keys.ToList(); foreach (string key in keys) { + // If the dictionary somehow doesn't have the key in question, continue + if (!dict.ContainsKey(key)) + { + logger.Warning("Input Dictionary does not contain key: " + key); + continue; + } + List roms = dict[key]; // If we somehow have a null list, just skip it @@ -2292,6 +2299,13 @@ namespace SabreTools.Helper keys = sortable.Keys.ToList(); foreach (string key in keys) { + // If the dictionary somehow doesn't have the key in question, continue + if (!sortable.ContainsKey(key)) + { + logger.Warning("SortedDictionary does not contain key: " + key); + continue; + } + List sortedlist = sortable[key]; DatItem.Sort(ref sortedlist, norename); sortable[key] = sortedlist;