Skip to content

Commit

Permalink
fix: Enumerator can be invalid when an item is deleted (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
homuler committed May 13, 2022
1 parent dcee215 commit d8e061a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void ClearUnusedKeys()
{
lock (((ICollection)_table).SyncRoot)
{
var deadKeys = _table.Where(x => !x.Value.TryGetTarget(out var target)).Select(x => x.Key);
var deadKeys = _table.Where(x => !x.Value.TryGetTarget(out var target)).Select(x => x.Key).ToArray();

foreach (var key in deadKeys)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ protected static void CompressCallbackStatus()
{
lock (((ICollection)_CallbackStatus).SyncRoot)
{
var deadKeys = _CallbackStatus.Where(x => !_InstanceTable.ContainsKey(x.Key)).Select(x => x.Key);
var deadKeys = _CallbackStatus.Where(x => !_InstanceTable.ContainsKey(x.Key)).Select(x => x.Key).ToArray();

foreach (var key in deadKeys)
{
Expand Down

0 comments on commit d8e061a

Please sign in to comment.