Skip to content

Commit d78b5ce

Browse files
HighCommander4kadircet
authored andcommitted
[clang][HeuristicResolver] Additional hardening against an infinite loop in simplifyType() (#126690)
1 parent a058741 commit d78b5ce

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
@@ -247,7 +247,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
247247
}
248248
return T;
249249
};
250-
while (!Type.isNull()) {
250+
// As an additional protection against infinite loops, bound the number of
251+
// simplification steps.
252+
size_t StepCount = 0;
253+
const size_t MaxSteps = 64;
254+
while (!Type.isNull() && StepCount++ < MaxSteps) {
251255
QualType New = SimplifyOneStep(Type);
252256
if (New == Type)
253257
break;

0 commit comments

Comments
 (0)