Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/coreclr/jit/rangecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ bool RangeCheck::BetweenBounds(Range& range, GenTree* upper, int arrSize)
if (range.LowerLimit().IsBinOpArray())
{
int lcns = range.LowerLimit().GetConstant();
if (lcns >= 0 || -lcns > arrSize)
// Use "lcns < -arrSize" rather than "-lcns > arrSize" to avoid signed
// overflow when lcns == INT_MIN.
assert(arrSize > 0);
if (lcns >= 0 || lcns < -arrSize)
{
return false;
}
Expand Down Expand Up @@ -236,8 +239,11 @@ bool RangeCheck::BetweenBounds(Range& range, GenTree* upper, int arrSize)
if (range.LowerLimit().IsBinOpArray())
{
int lcns = range.LowerLimit().GetConstant();
// len + lcns, make sure we don't subtract too much from len.
if (lcns >= 0 || -lcns > arrSize)
// len + lcns, make sure we don't subtract too much from len. Use
// "lcns < -arrSize" rather than "-lcns > arrSize" to avoid signed
// overflow when lcns == INT_MIN.
assert(arrSize > 0);
if (lcns >= 0 || lcns < -arrSize)
{
return false;
}
Expand Down
Loading