From 4bb55dc1b68e419ff7caac82c515fc733ad67cd7 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 29 Jul 2018 11:32:33 +1200 Subject: [PATCH] Copy entries to local variable --- Src/Newtonsoft.Json/DefaultJsonNameTable.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Src/Newtonsoft.Json/DefaultJsonNameTable.cs b/Src/Newtonsoft.Json/DefaultJsonNameTable.cs index a86a610d..10f2cc94 100644 --- a/Src/Newtonsoft.Json/DefaultJsonNameTable.cs +++ b/Src/Newtonsoft.Json/DefaultJsonNameTable.cs @@ -76,10 +76,11 @@ namespace Newtonsoft.Json hashCode -= hashCode >> 11; hashCode -= hashCode >> 5; - // make sure index is evaluated before accessing _entries, otherwise potential race condition causing IndexOutOfRangeException - var index = hashCode & _mask; + // make sure index is evaluated before accessing _entries, otherwise potential race condition causing IndexOutOfRangeException + var index = hashCode & _mask; + var entries = _entries; - for (Entry entry = _entries[index]; entry != null; entry = entry.Next) + for (Entry entry = entries[index]; entry != null; entry = entry.Next) { if (entry.HashCode == hashCode && TextEquals(entry.Value, key, start, length)) {