Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
  • Loading branch information
stephentoub and jkotas committed Apr 16, 2021
1 parent 15e02a1 commit dddee8f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/coreclr/vm/gchelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,7 @@ void PublishObjectAndNotify(TObj* &orObject, GC_ALLOC_FLAGS flags)

inline SIZE_T MaxArrayLength()
{
// Impose limits on maximum array length in each dimension to allow efficient
// implementation of advanced range check elimination in future. We have to allow
// higher limit for array of bytes (or one byte structs) for backward compatibility.
// Impose limits on maximum array length to prevent corner case integer overflow bugs
// Keep in sync with Array.MaxLength in BCL.
return 0X7FFFFFC7;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ private static int GetPrime(int min)
3, 7, 17, 37, 89, 197, 431, 919, 1931, 4049, 8419, 17519, 36353,
75431, 156437, 324449, 672827, 1395263, 2893249, 5999471,
11998949, 23997907, 47995853, 95991737, 191983481, 383966977, 767933981, 1535867969,
2146435069, Array.MaxLength // Array.MaxLength is not prime, but it is the largest possible array size. There's nowhere to go from here.
2146435069, 0x7FFFFFC7
// 0x7FFFFFC7 == Array.MaxLength is not prime, but it is the largest possible array size.
// There's nowhere to go from here. Using a const rather than the MaxLength property
// so that the array contains only const values.
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ public static bool IsValidNumberHandlingValue(JsonNumberHandling handling) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ValidateInt32MaxArrayLength(uint length)
{
#if BUILDING_INBOX_LIBRARY
if (length > Array.MaxLength)
#else
if (length > 0X7FEFFFFF) // prior to .NET 6, max array length for sizeof(T) != 1 (size == 1 is larger)
#endif
{
ThrowHelper.ThrowOutOfMemoryException(length);
}
Expand Down

0 comments on commit dddee8f

Please sign in to comment.