diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2011-04-08 12:44:05 +0200 |
---|---|---|
committer | Leandro Melo <leandro.melo@nokia.com> | 2011-04-08 13:24:11 +0200 |
commit | cd995e0826214febb45d827c4a6410cb48eed273 (patch) | |
tree | dfc3a1a07bf08a6f0a0eef1598c9fa56307d875c /src/shared/cplusplus | |
parent | 3875944c2a39a6a481d0241553a451cd96c60f20 (diff) | |
download | qt-creator-cd995e0826214febb45d827c4a6410cb48eed273.tar.gz |
Fix C++ model crash when evaluating deep expressions
Task-number: QTCREATORBUG-3831
Done-with: Roberto Raggi
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/Bind.cpp | 18 | ||||
-rw-r--r-- | src/shared/cplusplus/Bind.h | 6 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp index 0ca8e71ba9..a3291e400f 100644 --- a/src/shared/cplusplus/Bind.cpp +++ b/src/shared/cplusplus/Bind.cpp @@ -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) { diff --git a/src/shared/cplusplus/Bind.h b/src/shared/cplusplus/Bind.h index 986c57edfb..ec7c64dcf4 100644 --- a/src/shared/cplusplus/Bind.h +++ b/src/shared/cplusplus/Bind.h @@ -138,6 +138,9 @@ protected: void lambdaDeclarator(LambdaDeclaratorAST *ast); FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init); + virtual bool preVisit(AST *); + virtual void postVisit(AST *); + // AST virtual bool visit(ObjCSelectorArgumentAST *ast); virtual bool visit(AttributeAST *ast); @@ -297,6 +300,8 @@ protected: virtual bool visit(ArrayDeclaratorAST *ast); private: + static const int kMaxDepth; + Scope *_scope; ExpressionTy _expression; const Name *_name; @@ -306,6 +311,7 @@ private: int _objcVisibility; int _methodKey; bool _skipFunctionBodies; + int _depth; }; } // namespace CPlusPlus |