Skip to content

Commit 7a6bfdb

Browse files
committed
Safeguard against suspiciously large allocations.
If we run into this check, likely some computation has overflowed, but we're getting these values from many different type systems and language plugins, so it's still good to check it at the very end, even if these are bugs to fixed on their own. rdar://108385563
1 parent afb7653 commit 7a6bfdb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,14 @@ bool lldb_private::formatters::swift::UnsafeTypeSyntheticFrontEnd::Update() {
511511
return false;
512512

513513
m_element_stride = *stride;
514-
515514
if (m_children.empty()) {
516515
size_t buffer_size = num_children * m_element_stride;
516+
if (buffer_size > 512*1024*1024) {
517+
LLDB_LOG(GetLog(LLDBLog::DataFormatters),
518+
"Suspiciously large object: num_children={0}, stride={1}",
519+
num_children, m_element_stride);
520+
return false;
521+
}
517522
m_buffer_sp.reset(new DataBufferHeap(buffer_size, 0));
518523

519524
Status error;

0 commit comments

Comments
 (0)