Skip to content

Commit

Permalink
Handle possible array size overflow
Browse files Browse the repository at this point in the history
In the StackTraceArray::Allocate
  • Loading branch information
janvorli committed Jun 10, 2024
1 parent f774c60 commit 69d1e71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/vm/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ void StackTraceArray::Allocate(size_t size)
}
CONTRACTL_END;

size_t raw_size = size * sizeof(StackTraceElement) + sizeof(ArrayHeader);
S_SIZE_T raw_size = S_SIZE_T(size) * S_SIZE_T(sizeof(StackTraceElement)) + S_SIZE_T(sizeof(ArrayHeader));

if (!FitsIn<DWORD>(raw_size))
if (raw_size.IsOverflow() || !FitsIn<DWORD>(raw_size))
{
EX_THROW(EEMessageException, (kOverflowException, IDS_EE_ARRAY_DIMENSIONS_EXCEEDED));
}
Expand Down

0 comments on commit 69d1e71

Please sign in to comment.