Add adjacency row length check (#86716)
authorStefan <Tornhoof@users.noreply.github.com>
Fri, 26 May 2023 15:45:01 +0000 (17:45 +0200)
committerGitHub <noreply@github.com>
Fri, 26 May 2023 15:45:01 +0000 (16:45 +0100)
src/libraries/System.Text.Json/Common/JsonHelpers.cs

index 46f201c..939e6e8 100644 (file)
@@ -133,7 +133,7 @@ namespace System.Text.Json
                 // Iterate over the adjacency matrix, removing any occurrence of nextIndex.
                 for (int i = 0; i < adjacency.Count; i++)
                 {
-                    if (adjacency[i] is { } childMap && childMap[nextIndex])
+                    if (adjacency[i] is { } childMap && nextIndex < childMap.Length && childMap[nextIndex])
                     {
                         childMap[nextIndex] = false;