[clang] 8c0aa53 - Fix out-of-bound access in TransformNestedRequirement.

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 21 20:24:03 PST 2022


Author: Utkarsh Saxena
Date: 2022-12-22T05:20:31+01:00
New Revision: 8c0aa53b07caa604d58a0d83dc571d8fcb004972

URL: https://github.com/llvm/llvm-project/commit/8c0aa53b07caa604d58a0d83dc571d8fcb004972
DIFF: https://github.com/llvm/llvm-project/commit/8c0aa53b07caa604d58a0d83dc571d8fcb004972.diff

LOG: Fix out-of-bound access in TransformNestedRequirement.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiate.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index b23ae5c83d9e6..c4531470119bd 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2335,7 +2335,8 @@ TemplateInstantiator::TransformNestedRequirement(
     llvm::SmallVector<Expr *> Result;
     if (!SemaRef.CheckConstraintSatisfaction(
             nullptr, {Req->getConstraintExpr()}, Result, TemplateArgs,
-            Req->getConstraintExpr()->getSourceRange(), Satisfaction))
+            Req->getConstraintExpr()->getSourceRange(), Satisfaction) &&
+        !Result.empty())
       TransConstraint = Result[0];
     assert(!Trap.hasErrorOccurred() && "Substitution failures must be handled "
                                        "by CheckConstraintSatisfaction.");


        


More information about the cfe-commits mailing list