summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2019-04-10 20:25:07 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2019-04-10 20:25:07 +0000
commit66b6bb1766b3e5eea56b26fc91d03f1fccbe15e4 (patch)
tree6e510965e70a6a84c0c4df4304e3f5ee8aa2d3bd /clang/lib
parent6644d014dd98c8039d7aa1148aada8e2a2fee488 (diff)
downloadbcm5719-llvm-66b6bb1766b3e5eea56b26fc91d03f1fccbe15e4.tar.gz
bcm5719-llvm-66b6bb1766b3e5eea56b26fc91d03f1fccbe15e4.zip
Check i < FD->getNumParams() before querying
Summary: As was already stated in a previous comment, the parameter isn't necessarily referring to one of the DeclContext's parameter. We should check the index is within the range to avoid out-of-boundary access. Reviewers: gribozavr, rsmith, lebedev.ri Reviewed By: gribozavr, rsmith Subscribers: lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60055 Patch by Violet. llvm-svn: 358134
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index a7d03ddff36..e8f1dcca59c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2892,7 +2892,7 @@ static const Decl *getCanonicalParmVarDecl(const Decl *D) {
unsigned i = PV->getFunctionScopeIndex();
// This parameter might be from a freestanding function type within the
// function and isn't necessarily referring to one of FD's parameters.
- if (FD->getParamDecl(i) == PV)
+ if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
return FD->getCanonicalDecl()->getParamDecl(i);
}
}
OpenPOWER on IntegriCloud