Skip to content

Commit 7808946

Browse files
[clang][HeuristicResolver] Additional hardening against an infinite loop in simplifyType() (#126690)
1 parent e5a3d7a commit 7808946

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
258258
}
259259
return T;
260260
};
261-
while (!Current.Type.isNull()) {
261+
// As an additional protection against infinite loops, bound the number of
262+
// simplification steps.
263+
size_t StepCount = 0;
264+
const size_t MaxSteps = 64;
265+
while (!Current.Type.isNull() && StepCount++ < MaxSteps) {
262266
TypeExprPair New = SimplifyOneStep(Current);
263267
if (New.Type == Current.Type)
264268
break;

0 commit comments

Comments
 (0)