Skip to content

Commit

Permalink
Add adjacency row length check (#86716)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornhoof committed May 26, 2023
1 parent b1f1091 commit c525645
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libraries/System.Text.Json/Common/JsonHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static T[] TraverseGraphWithTopologicalSort<T>(T entryNode, Func<T, IColl
// 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;

Expand Down

0 comments on commit c525645

Please sign in to comment.