diff --git a/ArchiSteamFarm/Collections/ConcurrentList.cs b/ArchiSteamFarm/Collections/ConcurrentList.cs index d44f0b8f7..24fd3810f 100644 --- a/ArchiSteamFarm/Collections/ConcurrentList.cs +++ b/ArchiSteamFarm/Collections/ConcurrentList.cs @@ -49,12 +49,15 @@ public sealed class ConcurrentList : IList, IReadOnlyList where T : not public T this[int index] { get { + ArgumentOutOfRangeException.ThrowIfNegative(index); + using (Lock.ReaderLock()) { return BackingCollection[index]; } } set { + ArgumentOutOfRangeException.ThrowIfNegative(index); ArgumentNullException.ThrowIfNull(value); using (Lock.WriterLock()) { diff --git a/ArchiSteamFarm/Collections/ObservableConcurrentDictionary.cs b/ArchiSteamFarm/Collections/ObservableConcurrentDictionary.cs index 71f755323..8c19202e0 100644 --- a/ArchiSteamFarm/Collections/ObservableConcurrentDictionary.cs +++ b/ArchiSteamFarm/Collections/ObservableConcurrentDictionary.cs @@ -51,9 +51,14 @@ public sealed class ObservableConcurrentDictionary : IDictionary IReadOnlyDictionary.Values => Values; public TValue this[TKey key] { - get => BackingDictionary[key]; + get { + ArgumentNullException.ThrowIfNull(key); + + return BackingDictionary[key]; + } set { + ArgumentNullException.ThrowIfNull(key); ArgumentNullException.ThrowIfNull(value); if (BackingDictionary.TryGetValue(key, out TValue? savedValue) && EqualityComparer.Default.Equals(savedValue, value)) {