From 3b166a5c22c85a5360b4f76c1c8d656bb501c48c Mon Sep 17 00:00:00 2001 From: Gadfly Date: Sat, 11 May 2024 17:00:35 +0800 Subject: [PATCH] fix: avoid potential IndexOutOfRangeException in Models.User --- src/Models/User.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Models/User.cs b/src/Models/User.cs index 2ef770cf..ba1bebd6 100644 --- a/src/Models/User.cs +++ b/src/Models/User.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Concurrent; namespace SourceGit.Models { @@ -36,11 +36,11 @@ namespace SourceGit.Models var email = data.Substring(nameEndIdx + 1); User user = new User() { Name = name, Email = email }; - _caches.Add(data, user); + _caches.TryAdd(data, user); return user; } } - private static Dictionary _caches = new Dictionary(); + private static ConcurrentDictionary _caches = new ConcurrentDictionary(); } }