Skip to content

Commit fcb13f7

Browse files
committed
refuse to import C arrays that are longer than 4096
1 parent 792a50e commit fcb13f7

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,17 @@ namespace {
480480
Bridgeability::None);
481481
if (!elementType)
482482
return Type();
483+
484+
auto size = type->getSize().getZExtValue();
485+
// An array of size N is importat as an N-element tuple which
486+
// takes very long to compile. We choose 4096 as the upper limit because
487+
// we don't want to break arrays of size PATH_MAX.
488+
if (size > 4096)
489+
return Type();
483490

484491
TupleTypeElt elt(elementType);
485492
SmallVector<TupleTypeElt, 8> elts;
486-
for (size_t i = 0, size = type->getSize().getZExtValue(); i < size; ++i)
493+
for (size_t i = 0; i < size; ++i)
487494
elts.push_back(elt);
488495

489496
return TupleType::get(elts, elementType->getASTContext());

0 commit comments

Comments
 (0)