Check that there are not more attributes than
authorDuncan Sands <baldrick@free.fr>
Fri, 30 Nov 2007 15:52:20 +0000 (15:52 +0000)
committerDuncan Sands <baldrick@free.fr>
Fri, 30 Nov 2007 15:52:20 +0000 (15:52 +0000)
function parameters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index eb7c90f01cc1de11082a81be179ca8502ccfc00b..c3633ff97a11635c9fa916346c13d8ed5c6dda6f 100644 (file)
@@ -396,6 +396,10 @@ void Verifier::visitFunction(Function &F) {
   bool SawSRet = false;
 
   if (const ParamAttrsList *Attrs = F.getParamAttrs()) {
+    Assert1(Attrs->size() &&
+            Attrs->getParamIndex(Attrs->size()-1) <= FT->getNumParams(),
+            "Function has excess attributes!", &F);
+
     bool SawNest = false;
 
     for (unsigned Idx = 0; Idx <= FT->getNumParams(); ++Idx) {