From 0507ffebb12adf7d1ce98daedc7ba06a3fc70ce8 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Wed, 15 Sep 2004 02:32:15 +0000 Subject: [PATCH] When creating constant arrays check that the initializer vector is the same size as the one in the array type. llvm-svn: 16354 --- llvm/lib/VMCore/Constants.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 8148f44b0331..a029d8466bf4 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -245,6 +245,8 @@ ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) { ConstantArray::ConstantArray(const ArrayType *T, const std::vector &V) : Constant(T) { + assert(V.size() == T->getNumElements() && + "Invalid initializer vector for constant array"); Operands.reserve(V.size()); for (unsigned i = 0, e = V.size(); i != e; ++i) { assert((V[i]->getType() == T->getElementType() ||