https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/126690
None >From 28630abecc42c23527687b84be8cb4dbcd2ca5d9 Mon Sep 17 00:00:00 2001 From: Nathan Ridge <zeratul...@hotmail.com> Date: Tue, 11 Feb 2025 02:06:32 -0500 Subject: [PATCH] [clang][HeuristicResolver] Additional hardening against an infinite loop in simplifyType() --- clang/lib/Sema/HeuristicResolver.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp index 3cbf33dcdced38..adce403412f689 100644 --- a/clang/lib/Sema/HeuristicResolver.cpp +++ b/clang/lib/Sema/HeuristicResolver.cpp @@ -258,7 +258,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E, } return T; }; - while (!Current.Type.isNull()) { + // As an additional protection against infinite loops, bound the number of + // simplification steps. + size_t StepCount = 0; + const size_t MaxSteps = 64; + while (!Current.Type.isNull() && StepCount++ < MaxSteps) { TypeExprPair New = SimplifyOneStep(Current); if (New.Type == Current.Type) break; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits