From 9f801728868e37ba87b53f3b715e4a5c3b15e6e6 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Thu, 1 Aug 2024 22:15:11 -0700 Subject: [PATCH] Fix crash in CopyTo when fluffing up objects - FluffUpObjectIfNeeded can modify the set during iteration --- src/SIL.LCModel/DomainImpl/Vectors.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SIL.LCModel/DomainImpl/Vectors.cs b/src/SIL.LCModel/DomainImpl/Vectors.cs index 25b67be8..061a0cd5 100644 --- a/src/SIL.LCModel/DomainImpl/Vectors.cs +++ b/src/SIL.LCModel/DomainImpl/Vectors.cs @@ -425,7 +425,7 @@ public void CopyTo(T[] array, int arrayIndex) throw new ArgumentOutOfRangeException("arrayIndex"); int currentcopiedIndex = arrayIndex; - foreach (var cmObjectOrId in m_items) + foreach (var cmObjectOrId in m_items.ToArray()) // ToArray to avoid collection modified exception on object FluffUp { array[currentcopiedIndex++] = FluffUpObjectIfNeeded(cmObjectOrId); }