From 9af08763528307258d980c8c2710797422024964 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 7 Nov 2017 17:12:04 -0800 Subject: [PATCH] clone cached string resources don't share object references, need to be passed as new copies as the array contents can be modified need to clone on dict return to not pollute dict, and need to clone after dict add so that the first return doesn't equal the dict copy -- this one could be on the dict add... keep returns same. --- PKHeX.Core/Util/DataUtil.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Util/DataUtil.cs b/PKHeX.Core/Util/DataUtil.cs index 4f0745d9b..27fb9e5c8 100644 --- a/PKHeX.Core/Util/DataUtil.cs +++ b/PKHeX.Core/Util/DataUtil.cs @@ -78,7 +78,7 @@ public partial class Util public static string[] GetStringList(string f) { if (stringListCache.ContainsKey(f)) - return stringListCache[f]; + return (string[])stringListCache[f].Clone(); var txt = GetStringResource(f); // Fetch File, \n to list. if (txt == null) return new string[0]; @@ -86,7 +86,7 @@ public static string[] GetStringList(string f) for (int i = 0; i < rawlist.Length; i++) rawlist[i] = rawlist[i].Trim(); stringListCache.Add(f, rawlist); - return rawlist; + return (string[])rawlist.Clone(); } public static string[] GetStringList(string f, string l, string type = "text") => GetStringList($"{type}_{f}_{l}"); public static string[] GetNulledStringArray(string[] SimpleStringList)