summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplateInstantiate.cpp
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
commitb6c2a59e4dbc3456716d90b5b52712c5552d37d7 (patch)
treeaf00f3cc9a640a0ed000ce5065758c09ac706a84 /lib/Sema/SemaTemplateInstantiate.cpp
parent515b0570852864af5aef68ceb94454e00a507f01 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@358134 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index a7d03ddff3..e8f1dcca59 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/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);
}
}