Skip to content

Commit 69d1e71

Browse files
committed
Handle possible array size overflow
In the StackTraceArray::Allocate
1 parent f774c60 commit 69d1e71

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/coreclr/vm/object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,9 @@ void StackTraceArray::Allocate(size_t size)
14841484
}
14851485
CONTRACTL_END;
14861486

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

1489-
if (!FitsIn<DWORD>(raw_size))
1489+
if (raw_size.IsOverflow() || !FitsIn<DWORD>(raw_size))
14901490
{
14911491
EX_THROW(EEMessageException, (kOverflowException, IDS_EE_ARRAY_DIMENSIONS_EXCEEDED));
14921492
}

0 commit comments

Comments
 (0)