Fix C++ model crash when evaluating deep expressions

Task-number: QTCREATORBUG-3831
Done-with: Roberto Raggi
This commit is contained in:
Leandro Melo
2011-04-08 12:44:05 +02:00
parent 3875944c2a
commit cd995e0826
2 changed files with 23 additions and 1 deletions

View File

@@ -66,6 +66,8 @@
using namespace CPlusPlus;
const int Bind::kMaxDepth(100);
Bind::Bind(TranslationUnit *unit)
: ASTVisitor(unit),
_scope(0),
@@ -75,7 +77,8 @@ Bind::Bind(TranslationUnit *unit)
_visibility(Symbol::Public),
_objcVisibility(Symbol::Public),
_methodKey(Function::NormalMethod),
_skipFunctionBodies(false)
_skipFunctionBodies(false),
_depth(0)
{
}
@@ -291,6 +294,19 @@ FullySpecifiedType Bind::postfixDeclarator(PostfixDeclaratorAST *ast, const Full
return value;
}
bool Bind::preVisit(AST *)
{
++_depth;
if (_depth > kMaxDepth)
return false;
return true;
}
void Bind::postVisit(AST *)
{
--_depth;
}
// AST
bool Bind::visit(ObjCSelectorArgumentAST *ast)
{