From 2567df5dd296032c4b4fbd1cc3305ae5f9c6533b Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 20 Sep 2024 11:13:11 +0200 Subject: [PATCH] Fix potential crash --- LeStorage/StoredCollection.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LeStorage/StoredCollection.swift b/LeStorage/StoredCollection.swift index 17a2d65..2a0a557 100644 --- a/LeStorage/StoredCollection.swift +++ b/LeStorage/StoredCollection.swift @@ -334,7 +334,8 @@ public class StoredCollection: RandomAccessCollection, SomeCollecti defer { self._hasChanged = true } - for item in items { + let itemsArray = Array(items) // fix error if items is self.items + for item in itemsArray { if let index = self.items.firstIndex(where: { $0.id == item.id }) { self.items.remove(at: index) }