From ee2f8f2f7c4eacfa305a29fcd916d63c650ca847 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Thu, 16 May 2013 01:46:09 +0000 Subject: Return QualType() when a too large array is attempting to be created. This prevents further errors and some overflows in size calculations. One overflow was previously triggering an assert. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181970 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaType.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/Sema/SemaType.cpp') diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 0959f7d66a..e4eafc5ee7 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1549,10 +1549,12 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, // Is the array too large? unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(Context, T, ConstVal); - if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) + if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) { Diag(ArraySize->getLocStart(), diag::err_array_too_large) << ConstVal.toString(10) << ArraySize->getSourceRange(); + return QualType(); + } } T = Context.getConstantArrayType(T, ConstVal, ASM, Quals); -- cgit v1.2.3