Skip to content

Commit

Permalink
Bounds check ordinal in ThreeOptLayout::ConsiderEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
amanasifkhalid committed Jan 22, 2025
1 parent abf8e94 commit 3e4f2c9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5173,7 +5173,12 @@ void Compiler::ThreeOptLayout::ConsiderEdge(FlowEdge* edge)
assert(dstPos < compiler->m_dfsTree->GetPostOrderCount());

// Don't consider edges to or from outside the hot range (i.e. ordinal doesn't match 'blockOrder' position).
if ((srcBlk != blockOrder[srcPos]) || (dstBlk != blockOrder[dstPos]))
if ((srcPos >= numCandidateBlocks) || (srcBlk != blockOrder[srcPos]))
{
return;
}

if ((dstPos >= numCandidateBlocks) || (dstBlk != blockOrder[dstPos]))
{
return;
}
Expand Down

0 comments on commit 3e4f2c9

Please sign in to comment.